Configuration

The ~/.vimrc file provides Vim's default configuration. To create and open the file for editing, run the following in a terminal:

vim ~/.vimrc

Below are examples of Vim configurations that can be added to the .vimrc file. Lines beginning with a " are comments:

" Indent automatically depending on filetype
filetype indent on
set autoindent
" Turn on line numbering. Turn it off with "set nonu"
set number
" Set syntax on
syntax on
" Case insensitive search
set ic
" Higlhight search
set hls
" Wrap text instead of being on one line
set lbr
" Change colorscheme from default to delek
colorscheme delek

Other .vimrc configurations can be found at dotfiles. Note that some .vimrc files won't work if the correct plugins aren't installed.

Editing docbook documents with vim

To contribute to the Ubuntu Documentation, you will need to use the docbook format. If so, you might be interested in the VIM filetype pluginxmledit.

Add the following to your ~/.vimrc

map! ,e <emphasis>
map! ,p <para>
map <F3> v/>^Mx

If you are at the beginning of an opening XML tag you can just press F3 and the tag gets cut to the buffer. Go the end of the section and press 'p' (=paste) and it will be appended after the current char.

This is useful to add tags after the text is already written. A typical usecase is when it is necessary to add formatting to current documents which have been copy/pasted from a web site.

Editing the Ubuntu Wiki

You can use VIM to edit articles in the Ubuntu wiki. Since we use the MoinMoin engine, we can use the Vim syntax plugin moin to get syntax highlighting for the wiki text in vim. Enable the plugin by using the instructions in the previous link.

Just click the More Actions: drop down list on the page you want to edit. Then select Show Raw Text. Copy the source of the wiki page you are editing, and paste it into vim. If you are using the console version of vim, it might be a good idea to turn off autoindenting, as vim autoformats the text as you paste it. This is not a issue in the gui version of vim.