Vim fan
Vim fan

Reputation: 41

How to map angle brackets in Windows gVim?

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?

Upvotes: 3

Views: 2239

Answers (2)

DrAl
DrAl

Reputation: 72696

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

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

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

Upvotes: 4

Vim fan
Vim fan

Reputation: 41

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.

Upvotes: 1

Related Questions