Ubuntu: VIM

[sc:linux-category ]Having moved from OpenSUSE to Ubuntu I noticed something a little odd, VIM wasn’t working quite right.

Three things seemed broken:

  1. When in insert mode, I couldn’t move around, it instead inserted the control codes.
  2. It didn’t save the edit position from my last editing session.
  3. Syntax highlighting.

Doing a quick search turned up the first issue being the version of VIM that was installed.  By default Ubunutu installs VIM-tiny, which seems a little weird for a desktop distro, but was easy enough to fix, a simple “apt-get install vim” pulled down VIM-basic which worked as expected.

Saving the edit position by default required editing /etc/vim/vimrc, there are three lines you have to uncomment to enable it:

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

Similarly there are a couple of lines to take care of syntax highlighting:

" Vim5 and later versions support syntax highlighting. Uncommenting the next
 " line enables syntax highlighting by default.
 if has("syntax")
 syntax on
 endif
" If using a dark background within the editing area and syntax highlighting
 " turn on this option as well
 set background=dark

 

Overall they’re pretty easy things to do, but it’s yet another example of weird defaults in Ubuntu.

Greg

Greg is the head cat at JumbleCat, with over 20 years of experience in the computer field, he has done everything from programming to hardware solutions. You can contact Greg via the contact form on the main menu above.

More Posts - Website

Greg

Greg is the head cat at JumbleCat, with over 20 years of experience in the computer field, he has done everything from programming to hardware solutions. You can contact Greg via the contact form on the main menu above.