[英]Vim: when cursor is on the last line of a file, make 'down arrow' or 'j' move cursor to the end of the line
在许多文本编辑器中,当光标位于最后一行时,按down arrow
会将光标移到该行的末尾。 有没有办法在vim中做到这一点( down arrow
或j
)?
这与仅按$
相对。
这应该做您想要的。
nnoremap <expr> j (line('.') == line('$')) ? '$' : 'j'
nnoremap <expr> <DOWN> (line('.') == line('$')) ? '$' : '<DOWN>'
我们检查当前行是否为最后一行。 如果是我们映射j
至$
如果不是我们映射j
到j
。 ( <DOWN>
逻辑相同)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.