寫給自己看,小記一下

Vim 的功能一直都很強,已經是我得力的文字編輯器,包含一些小程式,也都是用
她來撰寫,之前自己的筆記已經不知道流落到哪裡了,一些很好用的功能,少用會
忘記,作一個小筆記


游標移動

^ 行首
$ 行尾
h 左
j, Ctrl + n 下
k Ctrl + p 上
l 右
( 句子
) 句子
{ 段落
} 段落

Ctrl + f 下一頁
Ctrl + b 上一頁
Ctrl + d 下半頁
Ctrl + u 上半頁
Ctrl + e 視窗下移一行
Ctrl + y 視窗上移一行
zz 游標所在位置移到視窗中間
H 視窗第一行
M 視窗中間
L 視窗最後一行

gg 第一行
G 最後一行
行號 gg 到行號的位置
`. 移到上一次編輯的位置

快捷按鍵


K 看游標所在字的文件
* 向後找游標所在字
# 向前找游標所在字
dd 刪一行,d 是刪除的意思,可以自行想像
:ls 顯示buffer 裡所有的檔案
:bp 編輯buffer 中,上一個檔案
:bn 編輯 buffer 中,下一個檔案
:b 1 編輯 buffer 中編號1號的檔案
:tabe 新增 tab
:tab ball 將buffer 中所有的檔案用 tab 開啟

folder 全關或全開 zi, 游標所在位置打開 zo,或是全開 zO,游標所在位置關閉 zc,或是全關 zC

:Exp 開檔案視窗
:Sex 分一個視窗,開檔案視窗
:r !date 插入 command date 的結果

視窗操作

Ctrl + w n 開新視窗
Ctrl + w o 只留目前所在視窗,其他關閉
Ctrl + w h 切換到上面的視窗,依此類推 hjkl
Ctrl + w r 視窗順時移動
Ctrl + w c 視窗關閉
Ctrl + w + 視窗上下變大
Ctrl + w - 視窗上下變小
Ctrl +w < 視窗左右變小 Ctrl +w > 視窗左右變大
插入模式
Ctrl + t 等於一個 tab
Ctrl + d 刪除一個tab 寬度
u undo
Ctrl + r redo

VISUAL 模式

按 v 進入 visual mode 開始選取,選取完,按 « 可以左移一個 tab, »可以右移
按 Ctrl + v 可以進入 block selection visual 模式
“ay 記入a暫存器 x刪除p貼上
gJ 合併無空格
J 合併


spell

set spell 開啟
set nospell 關閉
]s 下一個拼錯的字
[s 上一個拼錯的字
z= 看建議的字
zg 加入字典


Plugin

ctags 下載
http://ctags.sourceforge.net/

taglist 下載
http://www.vim.org/scripts/script.php?script_id=273

python_fold 下載
http://vim.sourceforge.net/scripts/script.php?script_id=515

xml.vim 下載
http://www.vim.org/scripts/script.php?script_id=301


NERD_tree.vim 下載
http://www.vim.org/scripts/script.php?script_id=1658



參考資料

Edward Lee 前輩的 大家來學VIM
http://www.study-area.org/tips/vim/

Graphical vi-vim Cheat Sheet

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

紅塵一隅間拾得

http://greenisland.csie.nctu.edu.tw/wp/category/comuter/vim/

Efficient Editing With vim

http://jmcpherson.org/editing.html

Vim Introduction and Tutorial
http://blog.interlinked.org/tutorials/vim_tutorial.html

Vim help
http://vimcdoc.sourceforge.net/doc/help.html