2013-05-16 52 views
1

由於vim響應鼠標滾輪,我已將less的尋呼機切換爲vimpagerVimpager腳本:非常神祕

不過最近通過編譯VIM 7.3的新版本,並加入了一系列真棒插件的更新我的vim設置後,vimpager不再做任何事情的邏輯,當我嘗試使用nN手冊頁搜索文本。

這真的很糟糕,所以我着手使用:verbose map追溯綁定。

從vimpager腳本(/usr/local/share/vim/vim73/macros/less.vim):

" Search 
noremap <script>/H$:call <SID>Forward()<CR>/ 
if &wrap 
    noremap <script> ? H0:call <SID>Backward()<CR>? 
else 
    noremap <script> ? Hg0:call <SID>Backward()<CR>? 
endif 

fun! s:Forward() 
    " Searching forward 
    noremap <script> n H$nzt<SID>L 
    if &wrap 
    noremap <script> N H0Nzt<SID>L 
    else 
    noremap <script> N Hg0Nzt<SID>L 
    endif 
    cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L 
endfun 

fun! s:Backward() 
    " Searching backward 
    if &wrap 
    noremap <script> n H0nzt<SID>L 
    else 
    noremap <script> n Hg0nzt<SID>L 
    endif 
    noremap <script> N H$Nzt<SID>L 
    cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L 
endfun 

call s:Forward() 

" Quitting 
noremap q :q<CR> 

這最後一個我得到的,它使一個很大的意義。但這H$nzt<SID>L是完全無法穿透的。

它到底在做什麼?

P.S.通過將s:Forward()s:Backward()這兩個功能變成空閒無操作功能,我已經完成了搜索。所以我都準備好了,但那些東西是做什麼的?

回答

0

您可以使用less中的滾輪。

反正...

H  "puts the cursor on the first printable character 
     "of the first visible line of the window. 
$  "moves the cursor to the end of that line 
n  "moves the cursor on the next match 
zt  "scrolls the current line at the top of the window 
<SID>L "executes the L mapping defined in the current script 

整個事情看起來像一個稍微令人費解企圖使Vim的n工作像lessn

+0

哪個終端對滾輪的響應較少?它只適用於使用MouseTerm SIMBL插件的Terminal.app。我不再使用Terminal.app,因爲iTerm2具有keymapping和我喜歡的其他功能(如最新版本中的斜體支持) –

+0

我沒有得到'H $ n'的用途。但謝謝你的經歷。 –

+0

老實說,我沒有得到「爲什麼」:它看起來像一個解決方法給我。我還在家中使用Gnome終端,在工作時使用iTerm。我知道滾輪在Gnome終端中工作較少,因爲我只是嘗試了它,但是在執行CLI工作時幾乎從不使用鼠標,所以我不確定它是否適用於iTerm。 – romainl