I have a function setup to run on InsertEnter autocmd. In the function I want to jump to a specific line.
So what I have tried (simplified) is this so far:
function JumpToLineBeforeScroll()
echom "function runs"
exe ":10"
return ""
endfunction
autocmd InsertEnter * call JumpToLineBeforeScroll() | set cul
I verified using mode() that while this function runs it is in normal mode (pls correct me if wrong). Function runs but the line jump is not working. How do I get this to work ?
Note: What I am actually trying to achieve is on mouse scroll while in insert mode, switch to normal mode, save the current line number and then scroll. Then once I press i to enter insert mode again (InsertEnter) I want to jump back to the last line I was on before scroll. As this would need some conditionals I want to keep this in a function instead of writing the entire code in the autocmd line itself.
Thanks!
So
giexists :)Now after learning about
giand realising how:normalworks, I've reached this config which works for my usecase perfectly. And turns outautocmdis not actually needed for this as:startinsertalso exists :)I'm still using
didScrollsince I dont always want to do agiwhenever I pressi. If that's the setup any navigation in normal mode would be pointless as I would be back to same line when enter back insert.