Beruflich Dokumente
Kultur Dokumente
Why Vim ?
Simple reason: once you are familiar with it, you cant get anything better.
Features like auto completion, syntax highligting, search / replace features
like anyother editors will encourage to use Vim.
Navigating with the keyboard is just way faster.
gVim a graphical version also available without need for console.
Programmer Friendly and Faster
Mostly Keyboard is enough or better way to work with editor
More than you need from text editor and its not an text editor
First Step
Command Mode
To get in Command mode press Esc key (twice to ensure)
I. editor command
Provides you following operations
insert, append, and delete, and other search and navigation commands.
NOTE: when you're in command mode you can't insert text immediately
II. last line mode command
Syntax:
:<command> <params|options>
Press Tab Key for options or auto-completion of commands
e.g:
:set colorscheme <tab>
You can enter command by typing
Esc :<command>
Insert Mode
To get in Insert Mode press i or a, when you are in Command mode
Once you enter in Insert mode you can see in last screen displaying -INSERT -Insert mode allows you to enter text
i will start enter Insert mode while cursor on character
a will start enter Insert mode by moving cusor to the next character
You can switch back to command mode by pressing Esc key from Insert mode
dd
Delete line
yy
Copy line
Paste line
iv:
u
undo
ctrl+r
redo
Delete character
gg
w/e
Combine command
dw
dG
dg
Yw/yG/yg
^/$
???
ww
???
ZZ
g<h,j,k,l>
or
g<arrow>
Move with the wrapped line (long text line broken in screen for
display purpose use :set wrap)
write to file
:w <file>
:q
quit
:q!
Force quit
:wq
:wq!
:ls
:n <file>
:bn/:bp
:b<n>
ctrl+6
:!<sh-cmd>
:.!<sh-cmd>
%
%<
:
%s/<pat>/<su
btext>/gc
Visual Mode
Visual mode is a selection mode. There are three types of Visual selection.
v select from text like a mouse cursor
V select full line by line
Ctrl + v select block, one of the prominent features of Vim
Combine the selection with command mode commands to do editing
e.g V select text press d to delete / y to copy / w t move word by word
v + w.. + <cmd>
V + G + <cmd>
(ctrl+v) + I + <text> +
Esc
(ctrl+v) + d/y/p
V+
s/<pat>/<subtext>/g
gv
Programmer Special
$ sudo apt-get install ctags
$ cd program-dir/
$ ctags -R #program specific option
$ vim <file1>.c/.php/.cpp/.java/.js etc...
Install gpm for mouse in terminal mode, select with mouse do middle click to
paste
gf
(ctrl+])
(ctrl+t)
(ctrl+6)
Match braces/brackets/macros
:split / :vsplit
Hints
.vimrc
In your home directory /home/varadhan/.vimrc add all the settings
:map
:set
:ab
Etc,. Settings will be loaded automatically
swp files
Swp files are created when you open file with prefix dot(.) and ext (.swp) its for
recovery. Make sure to close the files with write or force quit to clear the swp files.
Too many swp files will lead loss of data by mistakenly recovered file.
ctrl + z: DONT
YOUR FILE IS NOT SAVED LEAD TO DATA LOSS
Use :wq :q :q! Etc
$ vimtutor
VIM Learning
Its harder, but it pays you well.
Practise makes things better.