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
This commit is contained in:
parent
e361489536
commit
7f62180e7b
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=45121
1 changed files with 53 additions and 8 deletions
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue