程式設計雜筆

[程設雜筆] 搭配 nerdcommenter 寫智慧註解vimscript

覺得vim script是單位行數報酬率最高的程式碼~~
這一小時一行的script
nnoremap <expr> v:count == 0 ? “:v:count.’aa’
不知道會為未來掙得多少小時回報?

想說

[count]yy

[count]dd

很好用,於是打算來寫個

[count]aa

可以直接加上多行註解

然後寫了一個小時,不斷的改code,答案終於出來了

nnoremap <expr> v:count == 0 ? '':v:count.'aa'

附上這一段的所有程式碼

imap <C-a> <ESC><leader>c<space>i
nmap <C-a> <leader>c<space>
nmap aa <leader>c<space>
nmap AA <leader>c<space>
vmap a <leader>c<space>
vmap A <leader>c<space>
nnoremap <expr> v:count == 0 ? '':v:count.'aa'
nnoremap <expr> v:count == 0 ? '':v:count.'AA'

其實個人認為vim script的報酬率超高,不過網路上教寫vim script的資源實在是太少了……我查了好久,只查到這麼一篇

http://vi.stackexchange.com/questions/2543/how-can-i-map-dcountd

github

https://github.com/i314i/dotfiles/blob/master/.vimrc

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s