this post was submitted on 25 Mar 2025
4 points (83.3% liked)

VIM - Vi IMproved

1154 readers
1 users here now

For Vim enthusiasts and anyone interested in Vim/Neovim!

"VIM is the greatest editor since the stone chisel." - Dr. Jose Unpingco

#HJKL

founded 2 years ago
MODERATORS
 

I'm using the following snipped in my .vimrc to restore the cursor position when closing and opening a file:

au BufReadPost * \ if line("'"") > 0 && line("'"") <= line("$") && &filetype != "gitcommit" | \ execute("normal `"") | \ endif

This works fine in regular vim, but not when using sudoedit, which I just got myself used to using when editing root files. I understand it is because sudoedit creates temporary files and therefore will not restore the position because it sees it as a different file, but is there any workaround? Or should i just use sudo -E instead as it works fine there?

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here