Engler
Engler

Reputation: 23

gvim mapping does not run the command

I've just started to use gvim (v.7.4 under ubuntu 13.04) and trying to set up mapping. I have looked a lot of sources with similar heading, but seems there is no info about my problem.

Compatible mode is set to off. I'm using the following command for mapping:

map zz :echo 'Hello, World!'

When I try to run this command (by pressin zz combination in normal mode) gvim write this command (":echo 'Hello, World!'") to command line and waiting untill I press enter to run the command. But I expected to run the command, by pressing zz combination.

Am I missing something?

Thank you.

UPDATE: @Idan, quite weird because I was pretty sure that I was trying to do so. After you post I decided to do it one more time just for fun (because, was sure it did not work for me), but funny thing that it works now :).

I have looked mapped keys, by map command:

weird thing that now "CR" was written in blue color ( in contrast to black, when I was trying ). Seems now, gvim recongnized "CR" as a special sequnce. Don't know the reason why, but any way now I'm happy :).

@All, thanks for links and other tricks!

Upvotes: 0

Views: 157

Answers (1)

Idan Arye
Idan Arye

Reputation: 12603

map and co are sending keystrokes, so you need to explicitly tell it to send the "Enter" keystroke. You do it by using <Cr>:

map zz :echo 'Hello, World!'<Cr>

BTW, you should use noremap instead of remap, so if someone re-map parts of your command you wouldn't get affected by it:

noremap zz :echo 'Hello, World!'<Cr>

It usually doesn't matter, but can be very annoying in the rare cases it does.

Upvotes: 4

Related Questions