Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当光标在行之间移动时,我需要使用 autocmd 触发器。
现在我正在使用:
:autocmd CursorMoved * call MyFunc()
有了它,MyFunc 在每次光标移动时执行,但我只需要在光标向上或向下移动时触发(不是左右移动)
编辑:
用最后记录的行检查光标线对我有用。
if line(".") != s:recordedLine let s:recordedLine = line(".") ....
我不认为你可以做你想做的事。您可能需要MyFunc()每次都调用,但在函数中添加一个条件来决定是否执行该操作。也许你可以用它getchar()来判断是否j被k按下。或者您可以记录当前行号 ( let line=getline('.')) 并将其与之前的行号进行比较。
MyFunc()
getchar()
let line=getline('.')