I need a autocmd trigger to use when the cursor moves between lines.
Now I'm using:
:autocmd CursorMoved * call MyFunc()
With it, MyFunc is executed in each cursor movement, but I need a trigger only when cursor move up or down (not right and left)
EDIT:
Checking the cursor line with the last recorded line works for me.
if line(".") != s:recordedLine
let s:recordedLine = line(".")
....
I don't think you can do exactly what you are trying to do. You likely will need to call
MyFunc()
every time, but put a condition in the function to decide whether or not to do the action. Perhaps you could usegetchar()
to figure out if j or k was pressed. Or perhaps you can record the current line number (let line=getline('.')
)and compare it with the previous line number.