Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I increment/decrement non-alphanumeric ASCII values of characters in Vim?

Tags:

vim

ascii

I would like to increment the ASCII value of several rows of characters. Most of them are not alphanumeric, otherwise I could simply use :set nrformats+=alpha to make CTRL-A and CTRL-X work on them. Is there any native Vim way of incrementing and decrementing ASCII values, or do I need to script it?

like image 387
Christopher Bottoms Avatar asked Oct 08 '22 20:10

Christopher Bottoms


1 Answers

:help nr2char
:help char2nr

Example:

:%s/./\=nr2char(char2nr(submatch(0))+1)/g
like image 116
myki Avatar answered Oct 12 '22 22:10

myki