Why not use tabs (introduced in Vim 7)?
You can switch between tabs with :tabn
and :tabp
,
With :tabe <filepath>
you can add a new tab; and with a regular :q
or :wq
you close a tab.
If you map :tabn
and :tabp
to your F7/F8 keys you can easily switch between files.
If there are not that many files or you don't have Vim 7 you can also split your screen in multiple files: :sp <filepath>
. Then you can switch between splitscreens with Ctrl+W and then an arrow key in the direction you want to move (or instead of arrow keys, w for next and W for previous splitscreen)
As has been pointed out in a couple of other answers, the preferred method now is NOT to use smartindent, but instead use the following (in your .vimrc
):
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
In your [.vimrc:][1] file:
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
The help files take a bit of time to get used to, but the more you read, the better Vim gets:
:help smartindent
Even better, you can embed these settings in your source for portability:
:help auto-setting
To see your current settings:
:set all
As graywh points out in the comments, smartindent has been replaced by cindent which "Works more cleverly", although still mainly for languages with C-like syntax:
:help C-indenting
Best Answer
Try this
bufdo runs command for all buffers
http://vim.wikia.com/wiki/Run_a_command_in_multiple_buffers