To go to line
esc linno G ---> esc 5 G
to go to last line ---> G
to go to First line ---> 1 + G
u ----> undo
cntrl + r ----> redo
:set nu to show line no
:set nonu hide line no
:synt off Deactivate syntax
:synt on activate syntax
SEARCH and REPLACE String in VI
First occurrence on current line :s/OLD/NEW
Globally (all) on current line :s/OLD/NEW/g
Between two lines #,#: :#,#s/OLD/NEW/g
Every occurrence in file: :%s/OLD/NEW/g
Working with multiple files
:e filename Edit a file in a new buffer
:bnext (or :bn) go to next buffer
:bprev (of :bp) go to previous buffer
:bd delete a buffer (close a file)
:sp filename Open a file in a new buffer and split window
ctrl+ws Split windows
ctrl+ww switch between windows
ctrl+wq Quit a window
ctrl+wv Split windows vertically
# Scroll forward a page with ---- ctrl-f
# Scroll back a page with ---- ctrl-b
# Scroll forward half a page with ---- ctrl-d
# Scroll back half a page with ---- ctrl-u
#move forward to the beginning of a word with w or W
#move forward to the end of a word with e or E
#move backward to the beginning of a word with b or B
-------------------------
Some Vim settings
set tabstop=4 "number of chars to be inserted when tab is used"
set shiftwidth=4 "To change the no. of space chars inserted for indent"
set softtabstop=4 "makes the spaces feel like real tabs"
set expandtab "convert the tabs to spaces"
we can put it in .vimrc
Vim Link
http://www.vim.org/tips/tip.php?tip_id=12
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment