Quantcast
Channel: Linux by Examples » which
Viewing all articles
Browse latest Browse all 7

tabs in vim 7

0
0

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


Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images