someword
(Derek Olsen)
March 17, 2015, 7:57pm
1
I am trying to unlearn the use of :x to write/quit the file I am editing. I thought I had a brilliant solution using the following remap in my vimrc.
cmap x :echom “Use :w instead”
So this works great when I type :x however an unintended side effect is that i can’t search for anything with an x in it the map get’s triggered.
Any ideas on how to remap only :x and still allow /x in search ?
andyw8
(Andy Waite)
March 17, 2015, 10:47pm
2
I haven’t tried it, but I think cmdalias will make this pretty easy to do, you just need to define your own custom command first (e.g. Remindme) to echo the message.
someword
(Derek Olsen)
March 18, 2015, 3:09pm
3
Andy
thanks for the tip.
I ended up cobbling together this function. If it ends up failing me i’ll go the cmdalias route.
cnoremap x WhatXmap()
function! WhatXmap()
let cmdtype = getcmdtype()
if cmdtype == ‘:’
return “Use :w instead”
else
return “x”
endif
endfunction