2012年8月21日 星期二

vim basic

分為7個課程

一;

基本:                                                                           

h j k l 為vi/vim的方向向                                                                                                                                                                                  

i為進入插入模式. 輸入文字. 並用Esc來回到normal mode

x為刪除目前的字元, X為刪前一個(left)的字元

A 到這行的最後,並進入insert mode.

Extras:

u為回復上一動作

0 跳到行首,$則為跳行尾 ; ^則這行的第一個noo-blank

w,b,e 為沿著'words'移動(wrods is a sequence of all alphannumerc or punctuation signs)

W,B,E則為沿著'WORDS'移動(WORDS is sequence of any non-blank charater)

 

二:

Basic:

f 在這行中前往字母; F則為往後.

t及T和f相同,但是其字母的前面.

d(delete):dw,df-

c(change)同delete且進入insert mode

.  repeate 最後的動作.

Extras:

Prepend a count to any command /motion to repeat it that number of time:

d2w :刪除二個word.

d2t, :刪除到第二個comma.

2i :做二次的輸入字串 ,按Esc

cc 及 dd 為以行動作.

v 進入visual mode.V以行為單位

三:

Basic:

y : copy(也可動作在visual mode)

p : paste

P : paste before.

yy : copy current line

d,c,x : 除了動作外,也同樣有copy動作

Extras:

" + a-z :選擇yank/deltete/paste 選擇暫存器

"* or "+ :system clipboard(系統的)

四:

/ :基本的search motion

? :也是search motion 但是向後的.

n :為重複最後的search 動作, N為反向的direction

Extras:

* :search 目前遊標的words

# :同*,但是方向相反

五:

m+a-z :設定mark

`+a-z :跳到mark

'+character :跳到mark行中的,第一個non-blank

A-Z mark are global,a-z 為per-buffer

'+. 跳到最後修改的地方.

Macros :

使用q + a-z來開啓 recording.

Esc+q :exit recording.

@ + a-z : play recording

@@:play last recording.

六:

% : jump 對應的pairs of '(' ')' , '[' ,']' ,etc...

HML : jump 對scren的top ,middle/bottom

G :到檔案的最後.

-/+ :上下行移動.

( 及) 跳到目前文句(sentence)的前尾.

{及} 跳到上下一個空白行.

[[ 跳到前一個'{' 行.

]] 跳到前一個'}' 行.

七:

Basic:

J : joins the current line with the next one ,or all the lines in the current visual selection.

r + character 取代目前的一個字元.

C 同c $,修改到行尾.

D 同d $,刪除到行尾.

Y 同yy ,復制整行.

s 刪除目前的子元,並進入insert mode.

S 刪除這一行,及insert mode.

Extras:

> : indent one or more lines.

< : unindent.

~ 改變目前的字母的大小寫.

參考:

Graphical vi-vim Cheat Sheet and Tutorial

http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html