I am using Vim 7.4 in Windows 7.
I am trying to map F2 to the following ex-command,
execute "normal ggf\<tab>"| execute "normal \<c-q>G$d"| %s/ \+//g
using the following mapping command
:nmap <F2> :execute "normal ggf\<tab>" \| execute "normal \<c-q>G$d" \| :%s/ \+//g
but when I press F2, the following shows up
:execute "normal ggf\^I" | execute "normal \G$d" |%s/ \+//g
The <tab>
changes to ^I
and <c-q>
disappears. How can I prevent
those changes to execute the original ex-command?
Update:
Note: <c-q>
is the default visual block selection in Vim 7.4 in Windows.
^I
is the key code of<tab>
so it is normal that it appears like this (see:h i_CTRL-V
) and I think the same happens to<c-q>
. Now if your problem is that your command appears but is not executed, it is because you didn't put<CR>
at the end of the mapping which correspond to pressingEnter
after you wrote your command.<tab>
is same as^I
but I was unaware of the<CR>
. Unfortunately it still doesn't work. I get a E488 Trailing Error when executing:nunmap <F2> :execute "normal ggf\<tab>"|execute "normal \<c-q>G$d"|%s/ \+//g<CR>
and when I executenmap <F2> :execute "normal ggf\<tab>"|execute "normal \<c-q>G$d"<CR>
I get E121: Undefined variable: CR E15: Invalid Expression "normal\<c-q>G$d" Note: <c-q> is used for visual block selectionnunmap <F2>
if you want to remove the mapping from the key, no need to specify the expression of the mapping. For the second error I'm not sure but why do you use<c-q>
for visual block? You can use<c-v>
and if you use<c-q>
because you remapped<c-v>
then usenormal!
in your expression so that your mapping are not used.