tabs in vim 7

August 15th, 2006 mysurface Posted in ln, Text Manipulation, vi, vim, which | Hits: 28806 | 2 Comments »

This was amazing when I get to know that vim can do tab. Okay to do that, it is easy, what you need is to do a key binding. Create a file .vimrc into your home folder, and paste the lines bellow into it.

:map  <F4>:tabprevious<cr>
:map  <F3>:tabnext<cr>
:map  <C-t>:tabnew .<cr>
:imap  <F4>:tabprevious<cr>i
:imap  <F3>:tabnext<cr>i
:imap  <C-t>:tabnew .<cr>

For map, the key binding works under normal, visual mode and imap works even when you are in insert mode. When I press ctrl t, it opens up another tab and points you to the current directory, and you can search for your file. Press F3 F4 for next tab and previous. You can bind your key with other key besides Function key.

Bare in mind, this only works under vim 7. Check your vi / vim version with

vi --version
vim --version

If you find out that your vim is 7 but vi is 6, then you have to check your vi command is using which file. Usually vi is a symlink to vim, so check it out.

which vi

If your vi symlink is not point to the latest vim you have, redo the symlink. Do this combo to check where vi symlink point to

ls -l `which vi`

# Output:

lrwxrwxrwx 1 root root 20 2006-06-05 14:01 /usr/bin/vi -> /etc/alternatives/vi

Remove or move the old symlink, and recreate the symlink to point to the latest vim.

mv /usr/bin/{vi/vio}
ln -s /usr/local/bin/vim /usr/bin/vi

Okay done, when you want to access back the old version of vi, type vio

2 Responses to “tabs in vim 7”

  1. [...] The six lines later are for tabbing, discuss at  previous post [...]

  2. This is a useful write-up, I discovered your blog site checking yahoo for a related theme and arrived to this. I couldnt come across to much alternative details on this summary, so it was nice to discover this one. I will certainly be back to check out some other posts that you have another time.

Leave a Reply