diff --git a/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml b/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml index 0823ef1401..235c745997 100644 --- a/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml +++ b/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml @@ -40,18 +40,63 @@ Install from editors/vim or editors/vim-lite. + + Configuration + Edit ~/.vimrc, adding these lines: - 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 + 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() + + Process the file to create embedded tabs: + + &prompt.user; perl -i'' -pe 's/TAB/\t/g' ~/.vimrc + + + + Use + + Press P to reformat paragraphs. Press + T to replace groups of eight spaces with a + tab. +