1)
Search for a file recursively
Here ** means recursive search
:n **/*Manager.py
2)
Open another file
:e anotherfile.py
3)
How to get help
:help *search*
:help *searching*
:help *replacing*
Search for a file recursively
Here ** means recursive search
:n **/*Manager.py
2)
Open another file
:e anotherfile.py
3)
How to get help
:help *search*
:help *searching*
:help *replacing*
4)
How to Comment lines
a)
Replace the begining of each line by #
:%s/^/#/g
s ---> Replace
g ---> Global (global to each line)
% ---> The entire file
b)
Replace the begining of lines 2 to 10 by #
:2,10s/^/#/g
c)
Replace the begining of each line by hello
:%s/^/hello/g
5)
How to Delete Comments from config file
a)
Delete all lines containing string "#"
:g/#/d
g ---> Global (Global to entire file)
b)
Delete all lines containing string
:g/string/d
6)
How to replace a string of current line
a)
Replace the first occurence of Bill by Steve in current line
:s/Bill/Steve/
b)
Replace Bill by Steve in current line
:s/Bill/Steve/g
g ---> Global (global to current line)
c)
Replace Bill by Steve in all the file
:%s/Bill/Steve/g
s ---> Replace
% ---> The entire file
g ---> Global (Global to each line)
How to Comment lines
a)
Replace the begining of each line by #
:%s/^/#/g
s ---> Replace
g ---> Global (global to each line)
% ---> The entire file
b)
Replace the begining of lines 2 to 10 by #
:2,10s/^/#/g
c)
Replace the begining of each line by hello
:%s/^/hello/g
5)
How to Delete Comments from config file
a)
Delete all lines containing string "#"
:g/#/d
g ---> Global (Global to entire file)
b)
Delete all lines containing string
:g/string/d
6)
How to replace a string of current line
a)
Replace the first occurence of Bill by Steve in current line
:s/Bill/Steve/
b)
Replace Bill by Steve in current line
:s/Bill/Steve/g
g ---> Global (global to current line)
c)
Replace Bill by Steve in all the file
:%s/Bill/Steve/g
s ---> Replace
% ---> The entire file
g ---> Global (Global to each line)
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
ReplyDelete