alias - Aliasing a command in vim -


vim preferred text editor when program, , run particularly annoying issue.

frequently, when need save buffer , continue on other miscellaneous task, typical

:w 

however, – seems more 50% of time – manage capitalise :w. naturally, vim yells @ me because w invalid command

e492: not editor command: w 

my question how can 1 alias colon-commands in vim. particularly, exemplify how alias w w.

i aware of process map keys commands. unfortunately, not i'm looking for.

to leave completion untouched, try using

cnoreabbrev w w 

, replace w in command line w, if neither followed nor preceded word character, :w<cr> replaced :w<cr>, :write won't.

update

here how write now:

cnoreabbrev <expr> w ((getcmdtype() is# ':' && getcmdline() is# 'w')?('w'):('w')) 

as function:

fun! setupcommandalias(from, to)   exec 'cnoreabbrev <expr> '.a:from         \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'         \ .'? ("'.a:to.'") : ("'.a:from.'"))' endfun call setupcommandalias("w","w") 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -