Wednesday, January 21, 2009

open multiple files in tabs, vim 7 can do that.

Remember last time when I open multiple files using vim, it will be loaded and store at the back buffer, in order to bring it to front, you need to first save your current file with :w then :bn for next :bp for previous. But seems vim 7 support tabs, I would like to open multiple files in tab for each file.

vim -p file1 file2 file3

But we might forget to specified -p and open files in the old manner, which my key maps to utilized tab become useless. I realize that if open one file with -p doesn’t have much different without -p, therefore, I play a trick. I set an alias in .bashrc ( .bashrc at home directory).

Insert this into .bashrc:

alias vi="vim -p"

alias allows me to change the way of calling vim, when I type vi, bash shell will replace vi command with vim -p. Therefore, now i can open multiple files in tabs like

vi file1 file2 file3

Important: after changing the .bashrc, terminal have to be restart to see the effects.


To move to next tab use


to previous tab


Max Says:
February 8th, 2008 at 2:47 pm

It’s better to use gt and gT to move forward and backwards in the tabs, respectfully. That way you don’t have to enter command mode.

No comments: