Basic VI comannd.

Basic VI command - VI Shortcut Keys


Enter Text


i Insert text left of cursor

a Append text right of cursor


Editing Text


x Delete selected character

nx Delete n characters from selected characters

X Delete all character before cursor

dw Delete word

ndw (eg 3dw) Delete n words

dd Delete line

ndd Delete n lines

D Delete characters from cursor to end of line

r Replace character under cursor

cw Replace a word

ncw Replace n words

C Change text from cursor to end of line

o Insert blank line below cursor (ready for insertion)

O Insert blank line above cursor (ready for insertion)

J Join succeeding line to current cursor line

nJ Join n succeeding lines to current cursor line

u Undo last change

U Restore current line


Navigating Text


H Move left one space

j Move down one line

k Move up one line

l Move right one space

w Forward word by word

b Backward word by word

$ Moveto end of line

0 (zero) Move to beginning of line

H Move to top line of screen

M Move to middle line of screen

L Move to last line of screen

G Move to last line of file

1G Move to first line of file

<Control>f Scroll forward one screen

<Control>b Scroll backward one screen

<Control>d Scroll down one-half screen

<Control>u Scroll up one-half screen

n Repeat last search in same direction

N Repeat last search in opposite direction


Save and Close File


ZZ Save file and then quit

:w Save file

:q! Discard changes and quit file
Search & Replace


/i Search for a pattern which will you take you to the next occurrence of it.

?i Search for a pattern which will you take you to the previous occurrence of it.

* Go to the next occurrence of the current word under the cursor.

# Go to the previous occurrence of the current word under the cursor.

% Go to the matching braces, or parenthesis inside code.

:s/searchStr/newStr/g Search and replace all occurrences of searchStr in a line

:s/searchStr/newStr/gi Search and replace all occurrences of searchStr in a line (case insensative)

:%s/searchStr/newStr/g Search all lines and replace all occurrences of searchStr in a line with newStr

:%s/searchStr/newStr/gc Search and replace all occurrences of searchStr in all lines interactively. It will highlight the search string and ask you to replace it or move to next search string

参考:[url]http://feeds.dzone.com/~r/dzone/frontpage/~3/EN-VW-Kui1k/getting_back_to_vi_editor.html[/url]

[url]http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值