svn commit: r45121 - head/en_US.ISO8859-1/books/fdp-primer/editor-config

Warren Block wblock at FreeBSD.org
Wed Jun 25 13:45:56 UTC 2014


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 at 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">


More information about the svn-doc-all mailing list