Date: Wed, 25 Jun 2014 13:45:56 +0000 (UTC) From: Warren Block <wblock@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r45121 - head/en_US.ISO8859-1/books/fdp-primer/editor-config Message-ID: <201406251345.s5PDjuJs030000@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: wblock Date: Wed Jun 25 13:45:55 2014 New Revision: 45121 URL: http://svnweb.freebsd.org/changeset/doc/45121 Log: Update the vim editor config section, adding gjb's .vimrc. Also add a a post-processing step to avoid an embedded literal tab, and a short note on usage. PR: 191137 Submitted by: venture37@geeklan.co.uk Modified: head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml Modified: head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml Wed Jun 25 00:34:43 2014 (r45120) +++ head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml Wed Jun 25 13:45:55 2014 (r45121) @@ -40,18 +40,63 @@ <para>Install from <package>editors/vim</package> or <package>editors/vim-lite</package>.</para> + <sect2 xml:id="editor-config-vim-config"> + <title>Configuration</title> + <para>Edit <filename>~/.vimrc</filename>, adding these lines:</para> - <programlisting>augroup sgmledit - autocmd FileType sgml set formatoptions=cq2l " Special formatting options - autocmd FileType sgml set textwidth=70 " Wrap lines at 70 columns - autocmd FileType sgml set shiftwidth=2 " Automatically indent - autocmd FileType sgml set softtabstop=2 " Tab key indents 2 spaces - autocmd FileType sgml set tabstop=8 " Replace 8 spaces with a tab - autocmd FileType sgml set autoindent " Automatic indentation -augroup END</programlisting> + <programlisting>if has("autocmd") + au BufNewFile,BufRead *.sgml,*.ent,*.xsl,*.xml call Set_SGML() + au BufNewFile,BufRead *.[1-9] call ShowSpecial() +endif " has(autocmd) + +function Set_Highlights() + "match ExtraWhitespace /^\s* \s*\|\s\+$/ + highlight OverLength ctermbg=red ctermfg=white guibg=#592929 + match OverLength /\%71v.\+/ + return 0 +endfunction + +function ShowSpecial() + setlocal list listchars=tab:>>,trail:*,eol:$ + hi nontext ctermfg=red + return 0 +endfunction " ShowSpecial() + +function Set_SGML() + setlocal number + syn match sgmlSpecial "&[^;]*;" + setlocal syntax=sgml + setlocal filetype=xml + setlocal shiftwidth=2 + setlocal textwidth=70 + setlocal tabstop=8 + setlocal softtabstop=2 + setlocal formatprg="fmt -p" + setlocal autoindent + setlocal smartindent + " Rewrap paragraphs + :map P gqj + " Replace spaces with tabs + :map T :s/ /TAB/<CR> + call ShowSpecial() + call Set_Highlights() + return 0 +endfunction " Set_SGML()</programlisting> + <para>Process the file to create embedded tabs:</para> + + <screen>&prompt.user; <userinput>perl -i'' -pe 's/TAB/\t/g' ~/.vimrc</userinput></screen> + </sect2> + + <sect2 xml:id="editor-config-vim-use"> + <title>Use</title> + + <para>Press <keycap>P</keycap> to reformat paragraphs. Press + <keycap>T</keycap> to replace groups of eight spaces with a + tab.</para> + </sect2> </sect1> <sect1 xml:id="editor-config-emacs">
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406251345.s5PDjuJs030000>