'vim - Run ex command to go to line from function in normal mode
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
