tags:

views:

94

answers:

2

I code a lot of HTML and I'd like to map CTRL+> to &gt; and CTRL+< to &lt; respectively, to make it easier when typing out lots of text featuring those symbols.

After checking the Vim manual, I tried using imap <C->> &gt;, imap <C-\>> &gt; and even imap <C-S-.> &gt; but so far I've had no success. Any ideas?

+3  A: 

All the <C-X> type combinations are for "Ctrl+X", you need:

:imap < &lt;
:imap > &lt;

As an alternative, you could also consider using :ab:

:iab < &lt;
:iab > &gt;

Then you type <SPACE and you'll get &lt;. This allows you to type:

<a href

and get:

<a href

or type:

X < Y

and get:

X &lt; Y

Hope that helps, for more information, see:

:help :imap
:help :abbreviations
Al
+1  A: 

As a compromise, I've found I can do imap <M-.> &gt; and imap <M-,> &lt;, which allows me to use ALT+. to type &gt; and ALT+, to type &lt; respectively. I suspect that not all CTRL+<key> combinations are supported.

Vim fan
The easy way to check whether a CTRL+<key> can be mapped is to go into insert mode and type <C-V><C-(key)><ESC>. If you type Ctrl-V, Ctrl-., nothing will be entered, but if you type Ctrl-V Ctrl-D, you'll get ^D.
Al