Skip Navigation

Restore cursor position when using sudoedit?

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?

0 comments

No comments