vim hacks
DESCRIPTION
Vim Hacks @ COSCUPTRANSCRIPT
![Page 1: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/1.jpg)
VIM HacksWhy Vim
Vim 能幫助我們什麼 c9s / Cornelius林佑安
AIINK.com
![Page 2: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/2.jpg)
編輯器
![Page 3: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/3.jpg)
It doesn’t matter
![Page 4: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/4.jpg)
It does matter
![Page 5: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/5.jpg)
好的編輯器帶你上天堂差的編輯器帶你住套房
![Page 6: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/6.jpg)
敏捷開發
![Page 7: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/7.jpg)
敏捷
![Page 8: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/8.jpg)
太多選擇
![Page 9: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/9.jpg)
想當年...
![Page 10: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/10.jpg)
年輕不懂事
![Page 11: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/11.jpg)
第一次
![Page 12: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/12.jpg)
MicrosoftVisual Studio
![Page 13: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/13.jpg)
Eclipse
![Page 14: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/14.jpg)
Code Block
![Page 15: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/15.jpg)
Notepad++
![Page 16: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/16.jpg)
太多
![Page 17: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/17.jpg)
怎麼都沒有理想中的編輯器呢?
鬱卒了....
![Page 18: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/18.jpg)
於是....
![Page 19: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/19.jpg)
• 繼續嘗試其他編輯器
![Page 20: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/20.jpg)
• 繼續嘗試其他編輯器• 花銀子買 IDE , Editor
![Page 21: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/21.jpg)
• 繼續嘗試其他編輯器• 花銀子買 IDE , Editor
• 又再寫一個 XXX Editor ..
![Page 22: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/22.jpg)
• 繼續嘗試其他編輯器• 花銀子買 IDE , Editor
• 又再寫一個 XXX Editor ..
• 又或者....
![Page 23: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/23.jpg)
筆記本
![Page 24: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/24.jpg)
自從不用 Microsoft Windows 之後 ...
![Page 25: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/25.jpg)
GEdit
![Page 26: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/26.jpg)
Emacs
![Page 27: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/27.jpg)
TextMate
![Page 28: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/28.jpg)
VIM
![Page 29: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/29.jpg)
![Page 30: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/30.jpg)
最糟糕的編輯方式
![Page 31: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/31.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
![Page 32: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/32.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
Oops!
少了 “a”
![Page 33: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/33.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 34: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/34.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 35: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/35.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 36: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/36.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 37: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/37.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 38: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/38.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 39: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/39.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 40: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/40.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 41: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/41.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 42: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/42.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 43: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/43.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 44: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/44.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 45: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/45.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
x N
![Page 46: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/46.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
![Page 47: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/47.jpg)
#!/usr/bin/env perlmy $happiness = COS::CUP();
![Page 48: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/48.jpg)
#!/usr/bin/env perlmy $happiness = COS::CUP();
一百個類似的狀況 ?一百個類似的狀況 ?
![Page 49: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/49.jpg)
#!/usr/bin/env perlmy $happiness = COS::CUP();
一百個類似的狀況 ?
糟
![Page 50: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/50.jpg)
浪費時間移動游標
![Page 51: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/51.jpg)
The VIM way...
![Page 52: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/52.jpg)
#!/usr/bin/env perlmy $hppiness = COS::CUP();
VIM:
F h
![Page 53: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/53.jpg)
#!/usr/bin/env perlmy $happiness = COS::CUP();
VIM:
a append
![Page 54: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/54.jpg)
VIM
![Page 55: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/55.jpg)
VIM 不是
![Page 56: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/56.jpg)
IDE
![Page 57: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/57.jpg)
不是...
![Page 58: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/58.jpg)
![Page 59: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/59.jpg)
也不是...
![Page 60: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/60.jpg)
強而有力!!!
![Page 61: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/61.jpg)
強而有力!!!
喔喔喔喔!!!
![Page 62: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/62.jpg)
VIM 是
![Page 63: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/63.jpg)
VI Improved
![Page 64: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/64.jpg)
進階編輯器
![Page 65: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/65.jpg)
提高
![Page 66: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/66.jpg)
文字編輯效率
![Page 67: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/67.jpg)
Learning Curve
![Page 68: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/68.jpg)
各種 Vim
![Page 69: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/69.jpg)
各種 Vim
• Vim
![Page 70: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/70.jpg)
各種 Vim
• Vim
• gVim
![Page 71: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/71.jpg)
各種 Vim
• Vim
• gVim
• gVim Easy
![Page 72: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/72.jpg)
各種 Vim
• Vim
• gVim
• gVim Easy
• MacVim
![Page 73: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/73.jpg)
各種 Vim
• Vim
• gVim
• gVim Easy
• MacVim
• Vi in Emacs
![Page 74: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/74.jpg)
各種 Vim
• Vim
• gVim
• gVim Easy
• MacVim
• Vi in Emacs
• Vi in Bash
![Page 75: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/75.jpg)
各種 Vim
• Vim
• gVim
• gVim Easy
• MacVim
• Vi in Emacs
• Vi in Bash
• etc ...
![Page 76: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/76.jpg)
Features
![Page 77: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/77.jpg)
1.編輯模式Mode
![Page 78: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/78.jpg)
四種以上編輯模式
![Page 79: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/79.jpg)
INSERTNORMALVISUALSELECT
... et cetera
![Page 80: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/80.jpg)
[Ii]NSERTNORMAL[Vv]ISUAL
ESC
![Page 81: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/81.jpg)
1.1 Normal Mode
![Page 82: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/82.jpg)
Motion
![Page 83: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/83.jpg)
![Page 84: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/84.jpg)
丟掉方向鍵吧
![Page 85: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/85.jpg)
節省移動時間
![Page 86: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/86.jpg)
請愛用
![Page 87: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/87.jpg)
HJKL←↓↑→
![Page 88: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/88.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
![Page 89: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/89.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
Cursor
![Page 90: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/90.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
[{
![Page 91: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/91.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
f@
![Page 92: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/92.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
$
![Page 93: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/93.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
^
![Page 94: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/94.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
H 畫面最上方
![Page 95: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/95.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
M畫面中間行
![Page 96: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/96.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}L 畫面最下方
![Page 97: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/97.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
修改至行尾
![Page 98: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/98.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep }
sub func1 {
}
C並進入 Insert mode
![Page 99: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/99.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
![Page 100: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/100.jpg)
# comments ...
foreach my $foo ( @bar ) {
# 做點事情
my @outs = grep /pattern/ , @list; }
sub func1 {
}
%
![Page 101: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/101.jpg)
:h motion.txt
![Page 102: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/102.jpg)
1.2 Insert Mode
![Page 103: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/103.jpg)
Editing text
![Page 104: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/104.jpg)
Insert Mode
• i : Insert text before the cursor
![Page 105: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/105.jpg)
• i : Insert text before the cursor
• I : Insert text before the first non-blank in the line
Insert Mode
![Page 106: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/106.jpg)
• i : Insert text before the cursor
• I : Insert text before the first non-blank in the line
• a : Append text after the cursor
Insert Mode
![Page 107: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/107.jpg)
• i : Insert text before the cursor
• I : Insert text before the first non-blank in the line
• a : Append text after the cursor
• A : Append text at the end of the line
Insert Mode
![Page 108: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/108.jpg)
1.3 Visual Mode
![Page 109: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/109.jpg)
Select region
![Page 110: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/110.jpg)
Visual Mode
• v : start Visual mode per character.
![Page 111: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/111.jpg)
Visual Mode
• v : start Visual mode per character.
• V : start Visual mode linewise.
![Page 112: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/112.jpg)
Visual Mode
• v : start Visual mode per character.
• V : start Visual mode linewise.
• Ctrl-v : start Visual mode blockwise.
![Page 113: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/113.jpg)
Visual Mode
• v : start Visual mode per character.
• V : start Visual mode linewise.
• Ctrl-v : start Visual mode blockwise.
接上 operator 如 y (yank) , d (delete) , c (change) ... etc
![Page 114: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/114.jpg)
2.語法標記Syntax Highlight Support
![Page 115: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/115.jpg)
/opt/local/share/vim/vim72 $ ls -1 syntax/ | wc -l 520
包含五百多種語法設定檔
![Page 116: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/116.jpg)
可自訂 Syntax
![Page 117: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/117.jpg)
~/.vim/syntax/[filetype].vim
![Page 118: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/118.jpg)
~/.vim/syntax/[filetype].vim
syn match [id] [re] [options]
![Page 119: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/119.jpg)
~/.vim/syntax/[filetype].vim
syn match [id] [re] [options]syn region [id] start=[re] end=[re]
![Page 120: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/120.jpg)
~/.vim/syntax/[filetype].vim
syn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...
![Page 121: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/121.jpg)
~/.vim/syntax/[filetype].vim
syn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...
hi [id] guibg=[color] ctermfg=[color]
![Page 122: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/122.jpg)
:help syntax.txt
![Page 123: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/123.jpg)
3.編碼支援ENCODING
![Page 124: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/124.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
![Page 125: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/125.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
設定檔案編碼清單
![Page 126: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/126.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
設定檔案編碼清單 Vim 會從第一組編碼開始讀取檔案,若是失敗則會跳下一組編碼讀取檔案
![Page 127: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/127.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
檔案編碼
![Page 128: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/128.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
內部編碼
![Page 129: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/129.jpg)
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le
:set fenc=utf-8 enc=utf-8 tenc=utf-8
Terminal 編碼
![Page 130: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/130.jpg)
:help encoding
![Page 131: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/131.jpg)
4. 快捷鍵Key Mapping
![Page 132: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/132.jpg)
:map:nmap:vmap:imap:smap :xmap... more
![Page 133: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/133.jpg)
:map (all)
:nmap (normal mode)
:vmap (visual mode)
:imap (insert mode)
:smap (select mode)
:xmap (visual , select mode)... more
![Page 134: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/134.jpg)
:map (all)
:nmap (normal mode)
:vmap (visual mode)
:imap (insert mode)
:smap (select mode)
:xmap (visual , select mode)... more
最常用
最常用
最常用
![Page 135: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/135.jpg)
:nmap <C-c><C-c> :!gcc -Wall % -o %:r.out<CR>
Ctrl C Ctrl C
呼叫 GCC 編譯現在編輯的檔案並將輸出檔名命名為現在檔案名稱並取代副檔名為 .out
![Page 136: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/136.jpg)
nmap <tab> v>nmap <s-tab> v<
vmap <tab> >gvvmap <s-tab> <gv
Normal Mode 時,可用 Tab 及 Shift-Tab 做縮排
![Page 137: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/137.jpg)
nmap <tab> v>nmap <s-tab> v<
vmap <tab> >gvvmap <s-tab> <gv
Visual/Select Mode 時,也可用 Tab 及 Shift-Tab 做縮排
![Page 138: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/138.jpg)
nmap <tab> v>nmap <s-tab> v<
vmap <tab> >gvvmap <s-tab> <gv
Visual/Select Mode 時,也可用 Tab 及 Shift-Tab 做縮排
When mappings and menus are defined with the |:vmap| or |:vmenu| command they work
both in Visual mode and in Select mode. When these are used in Select mode Vim automatically switches to Visual mode, so
that the same behavior as in Visual mode is effective.
![Page 139: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/139.jpg)
imap <F2> <C-R>=strftime("%c")<CR>
在 Insert Mode 時,按下 F2 會插入時間戳記
![Page 140: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/140.jpg)
cmap <c-a> <home>cmap <c-e> <end>cnoremap <c-b> <left>cnoremap <c-d> <del>cnoremap <c-f> <right>cnoremap <c-n> <down>cnoremap <c-p> <up>
cnoremap <esc><c-b> <s-left>cnoremap <esc><c-f> <s-right>
讓 Command Mode 也有 Bash 的 Key Binding
![Page 141: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/141.jpg)
:h map.txt
![Page 142: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/142.jpg)
5.文字物件TEXT OBJECT
![Page 143: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/143.jpg)
Text Object
• word
• string
• paragraph
• block
⇛ action(yank,delete,change ...etc)
![Page 144: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/144.jpg)
v | c | d i | a { | [ | ( | “ | ‘
visualchangedelete
Inner ObjectAn Object
Region{ }[ ]( )“ “‘ ‘
Operator Mapping
Operator
![Page 145: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/145.jpg)
va{
![Page 146: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/146.jpg)
![Page 147: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/147.jpg)
function ( blah , blah )ci(
function ( )
function ( new_args )
![Page 148: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/148.jpg)
“Hello World”di”
“”
“Hello New World”
![Page 149: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/149.jpg)
6.分頁支援TAB PAPGES
![Page 150: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/150.jpg)
![Page 151: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/151.jpg)
:tabnew
![Page 152: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/152.jpg)
:tabnew:tabedit path/to/file
![Page 153: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/153.jpg)
:tabnew:tabedit path/to/file:tabfind path/to/file
![Page 154: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/154.jpg)
:help tabpage.txt
![Page 155: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/155.jpg)
7.程式碼折疊FOLDS
![Page 156: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/156.jpg)
FOLD IS
![Page 157: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/157.jpg)
![Page 158: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/158.jpg)
Fold Methods
![Page 159: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/159.jpg)
Syntax Fold
Fold Methods
![Page 160: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/160.jpg)
Syntax Fold
Fold Methods
:set foldmethod=syntax
以程式語言語法做為折疊規則。某些特定的設定可以參考
$VIMRUNTIME/syntax/*.vim
![Page 161: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/161.jpg)
以 Perl 為例:/opt/local/share/vim/vim72/syntax/perl.vim
if exists("perl_want_scope_in_variables")“ .....if exists("perl_extended_vars")“ ..... if exists("perl_fold")“ ..... 便可在 .vimrc 內設定啟用這些特
定的語法標記或折疊 (Fold)
let perl_fold = 1let perl_extended_vars = 1“ .... etc
![Page 162: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/162.jpg)
Syntax FoldMarker Fold
Fold Methods
![Page 163: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/163.jpg)
Syntax FoldMarker Fold
Fold Methods
:set foldmethod=marker
以特定標記作為折疊規則,預設是 “{{{“ 以及 “}}}”
![Page 164: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/164.jpg)
# fold this {{{function do_something {
echo “COSCUP”;
}# }}}
![Page 165: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/165.jpg)
Syntax FoldMarker FoldIndent Fold
Fold Methods
![Page 166: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/166.jpg)
Syntax FoldMarker FoldIndent Fold
Fold Methods
:set foldmethod=indent
以縮排作為折疊規則
![Page 167: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/167.jpg)
Syntax FoldMarker FoldIndent FoldManual Fold
Fold Methods
![Page 168: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/168.jpg)
:set foldmethod=manual
手動建立折疊區塊,以 z f 鍵建立。
![Page 169: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/169.jpg)
利用 autocmd 加上 mkview , loadview 來儲存手動建立的折疊區塊,儲存的折疊會被放在 ~/.vim/view/ 裡頭。
autocmd BufWinLeave *.* silent mkviewautocmd BufWinEnter *.* silent loadview
![Page 170: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/170.jpg)
Syntax FoldMarker FoldIndent FoldManual FoldExpr Fold (Custom Fold Function)
Fold Methods
![Page 171: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/171.jpg)
:set foldexpr=MyFoldLevel(v:lnum)
呼叫自訂的折疊函式
![Page 172: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/172.jpg)
Syntax FoldMarker FoldIndent FoldManual FoldExpr Fold (Custom Fold Function)
Diff Fold
Fold Methods
![Page 173: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/173.jpg)
8.Modeline & FileType
![Page 174: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/174.jpg)
ModeLine
![Page 175: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/175.jpg)
" vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author: Cornelius < cornelius.howl{at}gmail{dot}com >
![Page 176: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/176.jpg)
" vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author: Cornelius < cornelius.howl{at}gmail{dot}com >
開啟此檔時,使用 Marker 作為折疊,縮排為兩個空隔,將 Tab 延展為空白,折疊所有的 Fold (Level 0 以上)
![Page 177: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/177.jpg)
FileType
![Page 178: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/178.jpg)
~/.vim/ftplugin/ruby.vim
針對某種檔案類型的設定不一定都要寫在 vimrc 內
![Page 179: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/179.jpg)
~/.vim/filetype.vim
可在 filetype.vim 內定義新的檔案類型。
![Page 180: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/180.jpg)
9.格式化FORMATTING
![Page 181: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/181.jpg)
程式碼很亂,怎麼辦?
![Page 182: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/182.jpg)
要手動自己排嗎?
![Page 183: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/183.jpg)
:set equalprg=perltidy
![Page 184: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/184.jpg)
:set equalprg=perltidy
選擇文字區塊後,按下 “=” 鍵,可使用外部的 perltidy 程式來做格式化處理。
可針對特定區塊重新排列程式碼
![Page 185: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/185.jpg)
autocmd Filetype perl :set equalprg=perltidy
可使用 autocmd 針對檔案類型做 equalprg 設定
![Page 186: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/186.jpg)
autocmd Filetype c :set equalprg=indent
開啟 C 程式碼時,使用外部的 GNU Ident 程式來做格式化處理。
![Page 187: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/187.jpg)
SQL$ cat bin/sql-beautify.pl #!/usr/bin/env perluse warnings;use strict;use SQL::Beautify;local $/;my $sql = SQL::Beautify->new( query => <STDIN> , spaces => 4 , break => "\n" );print $sql->beautify;
autocmd Filetype sql :set equalprg=sql-beautify.pl
開啟 SQL 程式碼時,使用外部的 Filter 來做格式化處理。
![Page 188: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/188.jpg)
10. QuickFix
![Page 189: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/189.jpg)
:grep & :make
![Page 190: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/190.jpg)
:grep [pattern] [filepath]
![Page 191: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/191.jpg)
:grep [pattern] [filepath]
呼叫 grepprg (預設 vimgrep) 執行,並將 grep 的結果彙整至 QuickFix
![Page 192: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/192.jpg)
QuickFix Window
![Page 193: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/193.jpg)
:set grepprg=/path/to/grep
設置 grepprg (預設 VIM 內建 grep)
![Page 194: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/194.jpg)
:make
![Page 195: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/195.jpg)
:make
呼叫 makeprg (預設 make) 執行 Makefile. 並以該語言的 compiler
output parser 彙整結果。
![Page 196: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/196.jpg)
:set makeprg=gmake
設置 makeprg (預設 make)
![Page 197: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/197.jpg)
Result ⇛ QuickFix Window
![Page 198: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/198.jpg)
:copen
開啟 QuickFix Window
![Page 199: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/199.jpg)
:cclose
關閉 QuickFix Window
![Page 200: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/200.jpg)
:cnext
下一筆 Result
![Page 201: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/201.jpg)
:cprevious
上一筆 Result
![Page 202: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/202.jpg)
com! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 cclose unlet g:qfix_win else copen 10 let g:qfix_win = bufnr("$") enendf nn <leader>q :QFix<cr>
QuickFix Window Toggle
![Page 203: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/203.jpg)
com! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 cclose unlet g:qfix_win else copen 10 let g:qfix_win = bufnr("$") enendf nn <leader>q :QFix<cr>
QuickFix Window Toggle
nmap 至 “\q” , <leader> 預設為 “\” 鍵
![Page 204: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/204.jpg)
11. 插件Plugin
![Page 205: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/205.jpg)
SnipMate提供類似 TextMate 編輯器的程式碼片段完成功能。
![Page 206: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/206.jpg)
snippet cla class .. initialize .. end class ${1:`substitute(Filename(), '^.', '\u&', '')`} def initialize(${2:args}) ${3} end
end 自訂常用程式碼樣板
![Page 207: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/207.jpg)
DBExt.vim資料庫輔助插件,支援 Oracle, Sybase, MSSQL ,
MySQL, DBI 等等
![Page 208: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/208.jpg)
xml.vim提供 XML 相關輔助功能,如自動補完標籤等等。
![Page 209: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/209.jpg)
FuzzyFinder.vimFuzzy/Partial pattern explorer
![Page 210: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/210.jpg)
The_NERD_TREE.vim樹狀目錄檔案瀏覽
![Page 211: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/211.jpg)
The NERD Commenter
註解輔助工具
![Page 212: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/212.jpg)
taglist.vim透過 ctags 工具產生程式碼標籤
並可將 macro , function , variable 等資料整理出來
![Page 213: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/213.jpg)
cscopeC 程式碼追蹤輔助
![Page 214: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/214.jpg)
autocomplpop.vim
![Page 215: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/215.jpg)
MRUmost recently used
![Page 216: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/216.jpg)
bufexplorer.vimBuffer Explorer
![Page 217: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/217.jpg)
Rails.vim
![Page 218: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/218.jpg)
git-vim
![Page 219: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/219.jpg)
那麼,怎麼安裝呢?
![Page 220: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/220.jpg)
最原始的作法
![Page 221: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/221.jpg)
![Page 222: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/222.jpg)
![Page 223: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/223.jpg)
![Page 224: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/224.jpg)
![Page 225: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/225.jpg)
下載套件
![Page 226: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/226.jpg)
閱讀安裝步驟
![Page 227: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/227.jpg)
閱讀安裝步驟
太繁瑣!
![Page 228: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/228.jpg)
閱讀安裝步驟
太繁瑣!
![Page 229: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/229.jpg)
![Page 230: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/230.jpg)
VimanaVim script Manager
![Page 231: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/231.jpg)
• Vimball
• Archive File ( zip , rar )
• .vim file
![Page 232: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/232.jpg)
POWERED BY
Perl
![Page 233: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/233.jpg)
$ cpan Vimana
使用 CPAN 安裝 Vimana
![Page 234: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/234.jpg)
$ vimana search xml
搜尋
![Page 235: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/235.jpg)
$ vimana search xmlrrd.vim - Edit RRD data with Vim.qt.vim - tiny tool for the uic used in Qt from Trolltechsyntax-for-xul - Highlighting for XML User interface Language.maven2.vim - Compiler plugin for maven2 .... skip
![Page 236: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/236.jpg)
$ vimana info xml.vim
查詢 script 資訊
![Page 237: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/237.jpg)
$ vimana install xml.vim 安裝 xml.vim 外掛
![Page 238: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/238.jpg)
$ vimana install xml.vim$ vimana install rails.vim$ vimana install the-nerd-tree.vim$ vimana install taglist.vim$ vimana install snipmate$ vimana install fuzzyfinder.vimetc ...
ALL Works
![Page 239: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/239.jpg)
http://github.com/c9s/Vimana/tree/master
Git Repository
![Page 240: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/240.jpg)
ENJOY
![Page 241: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/241.jpg)
Thank You
![Page 242: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/242.jpg)
Demo如果有時間....
![Page 243: Vim Hacks](https://reader033.vdocument.in/reader033/viewer/2022042521/540dfeb78d7f728d7e8b4ba8/html5/thumbnails/243.jpg)
Q & A