Non-printable Characters

Easily access non-printable and other characters in Vim with CTRL-v.

At times we might want to use unprintable or other in characters not accessible on our keyboards. For example, if you’d like a search and replace expression to use a carriage return. To enter characters like this in Vim, type CTRL-v while in insert-mode. Then enter the decimal code. You can also use CTRL-m for newlines.

While in insert mode press CTRL-v and then CTRL-m to insert a newline. Or try CTRL-V and then 162 to get ¢. The screencast below captures the following substitution to drop each item onto an individual line:

%s/, /,^M /g

Note that the ^M is a single character inserted by using CTRL-vfollowed by CTRL-m.

Other characters can be inserted using their encoding number, CTRL-V 13 in the case of carriage return or CTRL-v 9 can be used to insert a horizontal tab. Here are some other characters you can insert, by typing their number after you’ve pressed CTRL-v in insert mode:

  • ¢ 162

  • £ 163

  • © 169

  • ® 174

Here’s a handy list for your reference. Just remember to go into Insert mode, then type CTRL-v, then type the decimal number.


Was this useful? Help us improve!

With your feedback, we can improve VimTricks. Click a link to vote: