V可視化選中當前行,根據光標可多行3d
ctrl+v 可視化塊blog
v可視化根據光標ip
行間移動ci
快速增刪改查ast
d 0 刪除當前位置到行首可視化
d $ 刪除當前位置到行尾cli
d t (" ] ) )符號 刪除直到某個符號亂碼
d a w 刪除單詞(包括空格) d i w 刪除單詞(不包括空格)bfc
dd 刪除當前行file
x 刪除字符
數字 + 命令,屢次執行 e.g. 4dd 刪除4行 4x 刪除4個單詞
r a 單個字符的修改
s a刪除當前字符,進入插入模式
R 不斷進行當前字符替換
S 刪除當前行,進入插入模式
c a w 刪除單詞 並進入插入模式
C 刪除當前行,進入插入模式
c t + 符號 刪除到某個符號,並進入插入模式
: set hls 匹配的詞高亮
: set incsearch 邊匹配邊高亮
搜索替換
搜索替換
: % s/profile/profile222/g
: 1,10 s/profile/profile222/g
:1,15 s/profile//n 計算1到15行出現profile的個數
:1,15 s/\<profile\>/profile222/g 利用正則匹配替換 「profile」 爲 profile222
多文件操做VIM
e.g
:e filename 打開多個文件
:ls 列出當前緩衝區
e.g : tabnew filename 打開新標籤文件
gt 在標籤裏切換
VIM 的 Text Object
e.g
viw 選中單詞 vaw 選中單詞(包括空格)
c i w 刪除單詞並變爲插入模式
c a w 刪除單詞(包括空格)並變爲插入模式
vi [ / "
ci [ / "
set autoindent
set paste 在插入模式粘貼拷貝代碼時不會格式混亂
set nopaste 使得換行時set autoindent繼續生效
「 a 指定寄存器a ,yy 複製到到寄存器a : reg a 查看寄存器 a的內容
「 a p 粘貼寄存器a的內容出來
: echo has('clipboard') 檢查是否有剪切板 返回1 表明有
: set clipboard=unamed 設置爲系統剪切板
: e ! 從新加載文件,不保存當前文本
解決粘貼亂碼 : set paste (set nopaste 恢復) 或者 " + 或者 : set clipboard=unamed
VIM 宏(macro)
qa " "
@a
: CTRL+ P上一次的命令
VIM 補全大法