DEV Community

Colin Bartlett
Colin Bartlett

Posted on • Originally published at vimtricks.substack.com

3 1

VimTrick: Non-printable Characters

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 ¢.

Over on our VimTricks post, we have a screencast that captures the following substitution to drop each item onto an individual line:

%s/, /,^M  /g
Enter fullscreen mode Exit fullscreen mode

Note that the ^M is a single character inserted by using CTRL-v followed 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.

Anyone here using this on a regular basis already? What kind of characters do you need to enter?

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay