Restore cursor position when using sudoedit?

2 years ago by Drukob to c/vim

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?

vim
vim

@lemmy.sdf.org

login for more options
1239
41
8

For Vim enthusiasts and anyone interested in Vim/Neovim!

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

#HJKL

go to feed...