haskellHacker
haskellHacker

Reputation: 63

How to "bind" a character to a vi command?

Sometimes, I am writing primarily in English and I need to enter a special unicode character, like the degree symbol or the Greek letter theta. However, the two option of either memorizing the Unicode hex value, or copy/pasting it from the Internet are both very unsatisfactory.

Is there a way I can create a custom command (say :theta) such that when I enter the command, it automatically inserts the special character exactly where I need it?

Upvotes: 3

Views: 95

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 754130

Lookup :abbr and :map for starters. I use :map quite often for sequences of vim commands, but more typically use yank and pull to deal with awkward characters. You might use "tyl to yank a letter (such as θ) into a named buffer (t in this case) and then pull it when needed (from command mode) with "tp. You can build up a repertoire if you're careful.

Upvotes: 0

Related Questions