# Open from start. vi -o file1 file2 # Open split screens horizontally. vi -O file1 file2 # Open split screens vertically. vim -d file1 file2 # OPen split screens vertically and compare. vimdiff file1 file2 # As above.
# Open while in vim. Ctrl-w s split the current file horizontally Ctrl-w v split the current file vertically :sp file open a new file screen horizontally :vsp file open a new file screen vertically
# Close. Ctrl-w c close current screen Ctrl-w q close current screen and if it's the last one exist vim
Cursor movements:
1 2 3 4 5
Ctrl-w h jump to the left screen Ctrl-w j jump to the below screen Ctrl-w k jump to the above screen Ctrl-w l jump to the right screen Ctrl-w w jump to the next screen
Change current screen position:
1 2 3 4
Ctrl-w H move the current screen to left Ctrl-w J move the current screen to below Ctrl-w K move the current screen to above Ctrl-w L move the current screen to right
vim -p file1 file2 # Open files in tabs :tabnew file open file in new tab :tabc close the current tab :tabo close all tabs but the current one :tabs view all opened tabs :tabp move cursor to the previous tab :tabn move cursor to the next tab
vi & shell
1 2
:shell open shell without leaving vi exitexit shell and go back to vi
tab
1 2 3 4 5 6
:set smarttab # decide smartly how many spaces for a tab from the content of the file. :set tabstop=4 # How many spaces is displayed for a tab. :set softtabstop=4 # ??? :set shiftwidth=4 # How many spaces is inserted for each tab key strike. :set expandtab # expandtab/noexpandtab: make tab to space or not. :retab # make all tabs to spaces