I am using NeoVim, and I automatically define an abbreviation for the string
W every time the commandline mode starts.
However, it seems that commandline mode includes the search modes as well.
I do not want the abbreviation to exist in the search modes, so I want to delete it if it exists.
mapcheck('W','c',v:true) to check if
W is defined as an abbreviation in command mode, but they do not seem to work.
'W' is the abbreviation I want to check for,
'c' stands for commandline mode, and
true is for abbreviation -- I think)
What am I doing wrong? Thanks
EDIT: adding my code for defining the abbreviation for
autocmd CmdlineEnter,CmdwinEnter :,q: cnoreabbrev W w !git add %
(this allows me to add the file to the local git repo by typing
EDIT: Thanks to the answers below, the solution is:
cnoremap <expr> W (getcmdtype() == ':') ? "w !git add %" : "W"
Thank y'all -- it is very useful.