:%s/pattern//gn
:%s/pattern//n
:10,50s/pattern//gn
0 or ^, $ or A(with insert of end of line)
cc changing line, cw changing word
dw word, dd line, 5dd
yy or Y, p
yw Copy word. Actually, it copies from the current cursor position till the end of the current word plus the white space after it.
yy Copy current line.
y$ Copy from current cursor position till the end of the line.
yG Copy from current cursor position till the end of the file.
:set hlsearch
CTRL-O : Retrace your movements in file in backwards.
CTRL-I : Retrace your movements in file in forwards.
h move one character left
j move one row down
k move one row up
l move one character right
w move to beginning of next word
b move to previous beginning of word
e move to end of word
W move to beginning of next word after a whitespace
B move to beginning of previous word before a whitespace
E move to end of word before a whitespace
All the above movements can be preceded by a count; e.g. 4j moves down 4 lines.
0 move to beginning of line
$ move to end of line
_ move to first non-blank character of the line
g_ move to last non-blank character of the line
gg move to first line
G move to last line
ngg move to n'th line of file (n is a number; 12gg moves to line 12)
nG move to n'th line of file (n is a number; 12G moves to line 12)
H move to top of screen
M move to middle of screen
L move to bottom of screen
zz scroll the line with the cursor to the center of the screen
zt scroll the line with the cursor to the top
zb scroll the line with the cursor to the bottom
Ctrl-D move half-page down
Ctrl-U move half-page up
Ctrl-B page up
Ctrl-F page down
Ctrl-O jump to last (older) cursor position
Ctrl-I jump to next cursor position (after Ctrl-O)
Ctrl-Y move view pane up
Ctrl-E move view pane down
r{char} replace the character under the cursor with {char}.
R Enter Insert mode, replacing characters rather than inserting
zz
:colo desert, zellner, pablo, delek, slate, torte, morning, evening, default
:tabedit file2
:tabnew file3
:tabs You can list all the open tabs using :
$ vim -p source.c source.h To open multiple files in tabs:
:split filename - split window horizontally and load filename
:vsplit file - vertical split and open file
:sview file - same as split, but readonly
:close - close current window
:1,10fo 10 lines folding
:za, zf
:zo open folding
:Sexplore Open the explorer in a horizontal
:Vexplore ) Open the explorer in a vertical
:Texplore Open the explorer in another tabpage using and exit using :q
:Ex to open the file explorer
f + space (jump next space), f + p (jump next p char)
d + f + space (delete till next space)
_vimrc file
source $VIMRUNTIME/vimrc_example.vim
set guifont=Courier_New:h12:cANSI:qDRAFT
set nu
set hlsearch
colo desert
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
function DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
asd
:%s/pattern//n
:10,50s/pattern//gn
0 or ^, $ or A(with insert of end of line)
cc changing line, cw changing word
dw word, dd line, 5dd
yy or Y, p
yw Copy word. Actually, it copies from the current cursor position till the end of the current word plus the white space after it.
yy Copy current line.
y$ Copy from current cursor position till the end of the line.
yG Copy from current cursor position till the end of the file.
:set hlsearch
CTRL-O : Retrace your movements in file in backwards.
CTRL-I : Retrace your movements in file in forwards.
h move one character left
j move one row down
k move one row up
l move one character right
w move to beginning of next word
b move to previous beginning of word
e move to end of word
W move to beginning of next word after a whitespace
B move to beginning of previous word before a whitespace
E move to end of word before a whitespace
All the above movements can be preceded by a count; e.g. 4j moves down 4 lines.
0 move to beginning of line
$ move to end of line
_ move to first non-blank character of the line
g_ move to last non-blank character of the line
gg move to first line
G move to last line
ngg move to n'th line of file (n is a number; 12gg moves to line 12)
nG move to n'th line of file (n is a number; 12G moves to line 12)
H move to top of screen
M move to middle of screen
L move to bottom of screen
zz scroll the line with the cursor to the center of the screen
zt scroll the line with the cursor to the top
zb scroll the line with the cursor to the bottom
Ctrl-D move half-page down
Ctrl-U move half-page up
Ctrl-B page up
Ctrl-F page down
Ctrl-O jump to last (older) cursor position
Ctrl-I jump to next cursor position (after Ctrl-O)
Ctrl-Y move view pane up
Ctrl-E move view pane down
r{char} replace the character under the cursor with {char}.
R Enter Insert mode, replacing characters rather than inserting
zz
:colo desert, zellner, pablo, delek, slate, torte, morning, evening, default
:tabedit file2
:tabnew file3
:tabs You can list all the open tabs using :
$ vim -p source.c source.h To open multiple files in tabs:
:split filename - split window horizontally and load filename
:vsplit file - vertical split and open file
:sview file - same as split, but readonly
:close - close current window
:1,10fo 10 lines folding
:za, zf
:zo open folding
:Sexplore Open the explorer in a horizontal
:Vexplore ) Open the explorer in a vertical
:Texplore Open the explorer in another tabpage using and exit using :q
:Ex to open the file explorer
f + space (jump next space), f + p (jump next p char)
d + f + space (delete till next space)
_vimrc file
source $VIMRUNTIME/vimrc_example.vim
set guifont=Courier_New:h12:cANSI:qDRAFT
set nu
set hlsearch
colo desert
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
function DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
asd
Comments
Post a Comment