这里是普通文章模块栏目内容页
5 涓濂界敤鐨勫紑鍙戣 Vim 鎻掍欢

5 涓濂界敤鐨勫紑鍙戣 Vim 鎻掍欢

銆銆鎴戠敤 Vim 宸茬粡瓒呰繃 20 骞翠簡锛屼袱骞村墠鎴戝喅瀹氭妸瀹冧綔涓烘垜鐨勯栬佹枃鏈缂栬緫鍣ㄣ傛垜鐢 Vim 鏉ョ紪鍐欎唬鐮併侀厤缃鏂囦欢銆佸崥瀹㈡枃绔犲強鍏跺畠浠绘剰鍙浠ョ敤绾鏂囨湰琛ㄨ揪鐨勪笢瑗裤俈im 鏈夊緢澶氳秴绾ф掔殑鍔熻兘锛屼竴鏃︿綘閫傚悎浜嗗畠锛屼綘鐨勫伐浣滀細鍙樺緱闈炲父楂樻晥銆

銆銆鍦ㄦ棩甯哥紪杈戝伐浣滀腑锛屾垜鏇村惧悜浜庝娇鐢 Vim 绋冲畾鐨勫師鐢熷姛鑳斤紝浣嗗紑婧愮ぞ鍖哄 Vim 寮鍙戜簡澶ч噺鐨勬彃浠讹紝鍙浠ユ墿灞 Vim 鐨勫姛鑳姐佹敼杩涗綘鐨勫伐浣滄祦绋嬪拰鎻愬崌宸ヤ綔鏁堢巼銆

銆銆浠ヤ笅鍒椾妇 5 涓闈炲父濂界敤鐨勫彲浠ョ敤浜庣紪鍐欎换鎰忕紪绋嬭瑷鐨勬彃浠躲

銆銆1銆丄uto Pairs

銆銆Auto Pairs 鎻掍欢鍙浠ュ府鍔╀綘鎻掑叆鍜屽垹闄ゆ垚瀵圭殑鏂囧瓧锛屽傝姳鎷鍙枫佸渾鎷鍙锋垨寮曞彿銆傝繖鍦ㄧ紪鍐欎唬鐮佹椂闈炲父鏈夌敤锛屽洜涓哄緢澶氱紪绋嬭瑷閮芥湁鎴愬规爣璁扮殑璇娉曪紝灏卞儚鍦嗘嫭鍙风敤浜庡嚱鏁拌皟鐢锛屾垨寮曞彿鐢ㄤ簬瀛楃︿覆瀹氫箟銆

銆銆Auto Pairs 鏈鍩烘湰鐨勫姛鑳芥槸鍦ㄤ綘杈撳叆涓涓宸︽嫭鍙锋椂浼氳嚜鍔ㄨˉ鍏ㄥ瑰簲鐨勫彟涓鍗婃嫭鍙枫傛瘮濡傦紝浣犺緭鍏ヤ簡涓涓 [锛屽畠浼氳嚜鍔ㄥ府浣犺ˉ鍏呭彟涓鍗 ]銆傜浉鍙嶏紝濡傛灉浣犵敤閫鏍奸敭鍒犻櫎寮澶寸殑涓鍗婃嫭鍙凤紝Auto Pairs 浼氬垹闄ゅ彟涓鍗娿

銆銆濡傛灉浣犺剧疆浜嗚嚜鍔ㄧ缉杩涳紝褰撲綘鎸変笅鍥炶溅閿鏃 Auto Pairs 浼氬湪鎭板綋鐨勭缉杩涗綅缃琛ュ叏鍙︿竴鍗婃嫭鍙凤紝杩欐瘮浣犳壘鍒版斁缃鍙︿竴鍗婄殑浣嶇疆骞堕夋嫨涓涓姝g‘鐨勬嫭鍙疯佺渷鍔插氫簡銆

銆銆渚嬪備笅闈㈣繖娈典唬鐮侊細

package main

import"fmt"

func main(){

x :=true

items :=[]string{"tv","pc","tablet"}

if x {

for _, i := range items

}

}

銆銆鍦 items 鍚庨潰杈撳叆涓涓宸﹁姳鎷鍙锋寜涓嬪洖杞︿細浜х敓涓嬮潰鐨勭粨鏋滐細

package main

import"fmt"

func main(){

x :=true

items :=[]string{"tv","pc","tablet"}

if x {

for _, i := range items{

|(cursor here)

}

}

}

銆銆Auto Pairs 鎻愪緵浜嗗ぇ閲忓叾瀹冮夐」(浣犲彲浠ュ湪 GitHub 涓婃壘鍒)锛屼絾鏈鍩烘湰鐨勫姛鑳藉凡缁忓緢璁╀汉鐪佹椂闂翠簡銆

銆銆2銆丯ERD Commenter

銆銆NERD Commenter 鎻掍欢缁 Vim 澧炲姞浜嗕唬鐮佹敞閲婄殑鍔熻兘锛岀被浼煎湪IDE涓娉ㄩ噴鍔熻兘銆傛湁浜嗚繖涓鎻掍欢锛屼綘鍙浠ヤ竴閿娉ㄩ噴鍗曡屾垨澶氳屼唬鐮併

銆銆NERD Commenter 鍙浠ヤ笌鏍囧噯鐨 Vim filetype 鎻掍欢閰嶅悎锛屾墍浠ュ畠鑳界悊瑙d竴浜涚紪绋嬭瑷骞朵娇鐢ㄥ悎閫傜殑鏂瑰紡鏉ユ敞閲婁唬鐮併

銆銆鏈鏄撲笂鎵嬬殑鏂规硶鏄鎸 Leader+Space 缁勫悎閿鏉ュ垏鎹㈡敞閲婂綋鍓嶈屻俈im 榛樿ょ殑 Leader 閿鏄 \銆

銆銆鍦ㄥ彲瑙嗗寲妯″紡涓锛屼綘鍙浠ラ夋嫨澶氳屼竴骞舵敞閲娿侼ERD Commenter 涔熷彲浠ユ寜璁℃暟娉ㄩ噴锛屾墍浠ヤ綘鍙浠ュ姞涓鏁伴噺 n 鏉ユ敞閲 n 琛屻

銆銆杩樻湁涓鏈夌敤鐨勭壒鎬 鈥淪exy Comment鈥 鍙浠ョ敤 Leader+cs 鏉ヨЕ鍙戯紝瀹冪殑鍧楁敞閲婇庢牸鏇存紓浜涓浜涖備緥濡備笅闈㈣繖娈典唬鐮侊細

package main

import"fmt"

func main(){

x :=true

items :=[]string{"tv","pc","tablet"}

if x {

for _, i := range items {

fmt.Println(i)

}

}

}

銆銆閫夋嫨 main 鍑芥暟涓鐨勬墍鏈夎岀劧鍚庢寜涓 Leader+cs 浼氬嚭鏉ヤ互涓嬫敞閲婃晥鏋滐細

package main

import"fmt"

func main(){

/*

*x := true

*items := []string{"tv", "pc", "tablet"}

*

*if x {

*for _, i := range items {

*fmt.Println(i)

*}

*}

*/

}

銆銆鍥犱负杩欎簺琛岄兘鏄鍦ㄤ竴涓鍧椾腑娉ㄩ噴鐨勶紝浣犲彲浠ョ敤 Leader+Space 缁勫悎閿涓娆″幓鎺夎繖閲屾墍鏈夌殑娉ㄩ噴銆

銆銆NERD Commenter 鏄浠讳綍浣跨敤 Vim 鍐欎唬鐮佺殑寮鍙戣呴兘蹇呰呯殑鎻掍欢銆

銆銆3銆乂IM Surround

#p#分页标题#e#

銆銆Vim Surround 鎻掍欢鍙浠ュ府浣犫滅幆缁曗濈幇鏈夋枃鏈鎻掑叆鎴愬圭殑绗﹀彿(濡傛嫭鍙锋垨鍙屽紩鍙)鎴栨爣绛(濡 HTML 鎴 XML 鏍囩)銆傚畠鍜 Auto Pairs 鏈夌偣鍎跨被浼硷紝浣嗘槸鐢ㄤ簬澶勭悊宸叉湁鏂囨湰锛屽湪缂栬緫鏂囨湰鏃舵洿鏈夌敤銆

銆銆姣斿備綘鏈変互涓嬩竴涓鍙ュ瓙锛

"Vim plugins are awesome !"

銆銆褰撲綘鐨勫厜鏍囧勪簬寮曡捣鏉ョ殑鍙ヤ腑浠讳綍浣嶇疆鏃讹紝浣犲彲浠ョ敤 ds" 缁勫悎閿鍒犻櫎鍙ュ瓙涓ょ鐨勫弻寮曞彿銆

Vim plugins are awesome !

銆銆浣犱篃鍙浠ョ敤 cs"' 鎶婂弻绔鐨勫弻寮曞彿鎹㈡垚鍗曞紩鍙凤細

'Vim plugins are awesome !'

銆銆鎴栬呭啀鐢 cs'[ 鏇挎崲鎴愪腑鎷鍙凤細

[Vim plugins are awesome !]

銆銆瀹冨圭紪杈 HTML 鎴 XML 鏂囨湰涓鐨勬爣绛惧挨鍏跺湪琛屻傚亣濡備綘鏈変互涓嬩竴琛 HTML 浠g爜锛

<p>Vim plugins are awesome !</p>

銆銆褰撳厜鏍囧湪 鈥渁wesome鈥 杩欎釜鍗曡瘝鐨勪换浣曚綅缃鏃讹紝浣犲彲浠ユ寜 ysiw<em> 鐩存帴缁欏畠鍔犱笂鐫閲嶆爣绛(<em>)锛

<p>Vim plugins are <em>awesome</em> !</p>

銆銆娉ㄦ剰瀹冭仾鏄庡湴鍔犱笂浜 </em> 闂鍚堟爣绛俱

銆銆Vim Surround 涔熷彲浠ョ敤 ySS 缂╄繘鏂囨湰骞跺姞涓婃爣绛俱傛瘮濡備綘鏈変互涓嬫枃鏈锛

<p>Vim plugins are <em>awesome</em> !</p>

銆銆浣犲彲浠ョ敤 ySS<div class="normal"> 鍔犱笂 div 鏍囩撅紝娉ㄦ剰鐢熸垚鐨勬佃惤鏄鑷鍔ㄧ缉杩涚殑銆

<divclass="normal">

        <p>Vim plugins are <em>awesome</em> !</p>

</div>

銆銆Vim Surround 鏈夊緢澶氬叾瀹冮夐」锛屼綘鍙浠ュ弬鐓 GitHub 涓婄殑璇存槑灏濊瘯瀹冧滑銆

銆銆4銆乂im Gitgutter

銆銆Vim Gitgutter 鎻掍欢瀵逛娇鐢 Git 浣滀负鐗堟湰鎺у埗宸ュ叿鐨勪汉鏉ヨ撮潪甯告湁鐢ㄣ傚畠浼氬湪 Vim 鐨勮屽彿鍒楁梺鏄剧ず git diff 鐨勫樊寮傛爣璁般傚亣璁句綘鏈夊備笅宸叉彁浜よ繃鐨勪唬鐮侊細

  1package main

  2

  3import"fmt"

  4

  5 func main(){

  6     x :=true

  7     items :=[]string{"tv","pc","tablet"}

  8

  9     if x {

 10         for _, i := range items {

 11             fmt.Println(i)

 12         }

 13     }

 14}

銆銆褰撲綘鍋氬嚭涓浜涗慨鏀瑰悗锛孷im Gitgutter 浼氭樉绀哄備笅鏍囪帮細

    1package main

    2

    3import"fmt"

    4

_   5 func main(){

#p#分页标题#e#

    6     items :=[]string{"tv","pc","tablet"}

    7

~   8     if len(items)>0{

    9         for _, i := range items {

   10             fmt.Println(i)

+  11             fmt.Println("------")

   12         }

   13     }

   14}

銆銆_ 鏍囪拌〃绀哄湪绗 5 琛屽拰绗 6 琛屼箣闂村垹闄や簡涓琛屻倊 琛ㄧず绗 8 琛屾湁淇鏀癸紝+ 琛ㄧず鏂板炰簡绗 11 琛屻

銆銆鍙﹀栵紝Vim Gitgutter 鍏佽镐綘鐢 [c 鍜 ]c 鍦ㄥ氫釜鏈変慨鏀圭殑鍧椾箣闂磋烦杞锛岀敋鑷冲彲浠ョ敤 Leader+hs 鏉ユ殏瀛樻煇涓鍙樻洿闆嗐

銆銆杩欎釜鎻掍欢鎻愪緵浜嗗瑰彉鏇寸殑鍗虫椂瑙嗚夊弽棣堬紝濡傛灉浣犵敤 Git 鐨勮瘽锛屾湁浜嗗畠绠鐩存槸濡傝檸娣荤考銆

銆銆5銆乂IM Fugitive

銆銆Vim Fugitive 鏄鍙︿竴涓灏 Git 宸ヤ綔娴侀泦鎴愬埌 Vim 涓鐨勮秴妫掓彃浠躲傚畠瀵 Git 鍋氫簡涓浜涘皝瑁咃紝鍙浠ヨ╀綘鍦 Vim 閲岀洿鎺ユ墽琛 Git 鍛戒护骞跺皢缁撴灉闆嗘垚鍦 Vim 鐣岄潰閲屻傝繖涓鎻掍欢鏈夎秴澶氱殑鐗规э紝鏇村氫俊鎭璇疯块棶瀹冪殑 GitHub 椤圭洰椤甸潰銆

銆銆杩欓噷鏈変竴涓浣跨敤 Vim Fugitive 鐨勫熀纭 Git 宸ヤ綔娴佺ず渚嬨傝炬兂鎴戜滑宸茬粡瀵逛笅闈㈢殑 Go 浠g爜鍋氬嚭淇鏀癸紝浣犲彲浠ョ敤 :Gblame 璋冪敤 git blame 鏉ユ煡鐪嬫瘡琛屾渶鍚庣殑鎻愪氦淇℃伅锛

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    1package main

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    2

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    3import"fmt"

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    4

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹_   5 func main(){

#p#分页标题#e#

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    6     items :=[]string{"tv","pc","tablet"}

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    7

00000000(NotCommittedYet2018-12-0518:55:00-0500)鈹倊   8     if len(items)>0{

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹    9         for _, i := range items {

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹   10             fmt.Println(i)

00000000(NotCommittedYet2018-12-0518:55:00-0500)鈹+  11             fmt.Println("------")

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹   12         }

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹   13     }

e9949066 (RicardoGerardi   2018-12-0518:17:19-0500)鈹   14}

銆銆鍙浠ョ湅鍒扮 8 琛屽拰绗 11 琛屾樉绀鸿繕鏈鎻愪氦銆傜敤 :Gstatus 鍛戒护妫鏌ヤ粨搴撳綋鍓嶇殑鐘舵侊細

  1#On branch master

  2#Your branch is up to datewith'origin/master'.

  3#

  4#Changesnot staged for commit:

  5#   (use"git add <file>..." to update what will be committed)

  6#   (use"git checkout -- <file>..." to discard changes in working directory)

  7#

#p#分页标题#e#

  8#       modified:   vim-5plugins/examples/test1.go

  9#

 10no changes added to commit (use"git add"and/or"git commit -a")

--------------------------------------------------------------------------------------------------------

    1package main

    2

    3import"fmt"

    4

_   5 func main(){

    6     items :=[]string{"tv","pc","tablet"}

    7

~   8     if len(items)>0{

    9         for _, i := range items {

   10             fmt.Println(i)

+  11             fmt.Println("------")

   12         }

   13     }

   14}

銆銆Vim Fugitive 鍦ㄥ垎鍓茬殑绐楀彛閲屾樉绀 git status 鐨勮緭鍑虹粨鏋溿備綘鍙浠ュ湪璇ヨ屾寜涓 - 閿鐢ㄨユ枃浠剁殑鍚嶅瓧鏆傚瓨杩欎釜鏂囦欢鐨勬彁浜わ紝鍐嶆寜涓娆 - 鍙浠ュ彇娑堟殏瀛樸傝繖涓淇℃伅浼氶殢鐫浣犵殑鎿嶄綔鑷鍔ㄦ洿鏂帮細

  1#On branch master

  2#Your branch is up to datewith'origin/master'.

  3#

  4#Changes to be committed:

  5#   (use"git reset HEAD <file>..." to unstage)

  6#

  7#       modified:   vim-5plugins/examples/test1.go

  8#

--------------------------------------------------------------------------------------------------------

    1package main

    2

    3import"fmt"

    4

_   5 func main(){

    6     items :=[]string{"tv","pc","tablet"}

    7

~   8     if len(items)>0{

    9         for _, i := range items {

   10             fmt.Println(i)

#p#分页标题#e#

+  11             fmt.Println("------")

   12         }

   13     }

   14}

銆銆鐜板湪浣犲彲浠ョ敤 :Gcommit 鏉ユ彁浜や慨鏀逛簡銆俈im Fugitive 浼氭墦寮鍙︿竴涓鍒嗗壊绐楀彛璁╀綘杈撳叆鎻愪氦淇℃伅锛

  1vim-5plugins:Updated test1.go example file

  2#Please enter the commit message for your changes.Lines starting

  3#with'#' will be ignored,and an empty message aborts the commit.

  4#

  5#On branch master

  6#Your branch is up to datewith'origin/master'.

  7#

  8#Changes to be committed:

  9#       modified:   vim-5plugins/examples/test1.go

 10#

銆銆鎸 :wq 淇濆瓨鏂囦欢瀹屾垚鎻愪氦锛

[master c3bf80f]vim-5plugins:Updated test1.go example file

 1file changed,2 insertions(+),2 deletions(-)

Press ENTER or type command to continue

銆銆鐒跺悗浣犲彲浠ュ啀鐢 :Gstatus 妫鏌ョ粨鏋滃苟鐢 :Gpush 鎶婃柊鐨勬彁浜ゆ帹閫佸埌杩滅▼銆

  1#On branch master

  2#Your branch is ahead of 'origin/master' by 1 commit.

  3#   (use"git push" to publish your local commits)

  4#

  5 nothing to commit, working tree clean

銆銆Vim Fugitive 鐨 GitHub 椤圭洰涓婚〉鏈夊緢澶氬睆骞曞綍鍍忓睍绀轰簡瀹冪殑鏇村氬姛鑳藉拰宸ヤ綔娴侊紝濡傛灉浣犲枩娆㈠畠骞舵兂澶氬︿竴浜涳紝蹇鍘荤湅鐪嬪惂銆

銆銆鎺ヤ笅鏉?

銆銆杩欎簺 Vim 鎻掍欢閮芥槸绋嬪簭寮鍙戣呯殑绁炲櫒!杩樻湁鍙﹀栦袱绫诲紑鍙戣呭父鐢ㄧ殑鎻掍欢锛氳嚜鍔ㄥ畬鎴愭彃浠跺拰璇娉曟鏌ユ彃浠躲傚畠浜涘ぇ閮芥槸鍜屽叿浣撶殑缂栫▼璇瑷鐩稿叧鐨勶紝浠ュ悗鎴戜細鍦ㄤ竴浜涙枃绔犱腑浠嬬粛瀹冧滑銆

銆銆浣犲湪鍐欎唬鐮佹椂鏄鍚︾敤鍒颁竴浜涘叾瀹 Vim 鎻掍欢?璇峰湪璇勮哄尯鐣欒█鍒嗕韩銆

銆銆鏈鏂囪浆杞戒簬锛https://linux.cn/article-10563-1.html

銆銆鍘熸枃: https://opensource.com/article/19/1/vim-plugins-developers

銆銆浣滆咃細Ricardo Gerardi 璇戣咃細pityonline

收藏
0
有帮助
0
没帮助
0