Non-printable Characters

3.4
(385)

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.

How useful was this tip?

Average rating 3.4 / 5. Vote count: 385

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Andy Libby

36 Posts

Rider of bicycles. Writer of code. User of Vim.
View all posts