I have a file-watcher system which triggers some compilations upon time-stamp changes in the source file I am editing. I have the obsessive habit of using :w
quite a few times during my editing session.
Is there a way to remap :w
to :up
?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI have a file-watcher system which triggers some compilations upon time-stamp changes in the source file I am editing. I have the obsessive habit of using :w
quite a few times during my editing session.
Is there a way to remap :w
to :up
?
I had added below in my .vimrc earlier based on this post.
cnoreabbrev <expr> w getcmdtype() == ":" && getcmdline() == 'w' ? 'up' : 'w'
Alternatively, there is a plugin which does this too.
Hope this helps.
gecmdline() =~ '^w$'
. This way when you type w
in the middle of the command (like when you're calling a window-local variable w:var
) it won't expand.
– Tumbler41
Jun 7 '18 at 14:03