In Neovim, the cursor shape automatically changes based on the mode you are in. I am writing a function in which I temporarily want to change what the cursor looks like in insert mode, then enter insert mode and do something, return to normal mode, and then revert to the defaults. I tried that with this function:
function! Cache()
let oldcursor = &guicursor
let &guicursor = "i:block"
call feedkeys("a\<c-x>\<c-o>\<escape>")
let &guicursor = oldcursor
endfunction
But this didn't work.
It didn't return the &guicursor
value to the oldcursor
after running the line before it.
I wanted it to first run call feedkeys("\<c-x>\<c-o>\<escape>")
, and then run let &guicursor = oldcursor
.
But it seemed like it didn't wait for the feedkeys
to finish before returning the originial value of guicursor
.