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

Warren Block <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
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:	[email protected]

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 "&amp;[^;]*;"
+    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/&lt;CR&gt;
+    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">
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-doc-all
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.