0

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 ?

1

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.

  • 1
    I prefer 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.