2013-05-16 62 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