Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to add spacing every 4 characters in vi?

Tags:

vi

Is it possible to add spacing every 4 characters in vi? And if it is, what's a good google term to search for to learn how to do similar stuff?

like image 560
funk-shun Avatar asked Jan 31 '11 05:01

funk-shun


People also ask

How do I insert multiple lines at the beginning of vim?

vim Inserting text Insert text into multiple lines at once Press Ctrl + v to enter into visual block mode. Use ↑ / ↓ / j / k to select multiple lines. Press Shift + i and start typing what you want. After you press Esc , the text will be inserted into all the lines you selected.


1 Answers

To add a space every 4 characters you could use the following command (at least in VIM):

:%s/\(....\)/\1 /g

If you Google "VIM Substitution" you should end up with some useful examples.

Example:

To add a space every 4 characters you could use

becomes

To a dd a  spa ce e very  4 c hara cter s yo u co uld  use 
like image 199
Jeffy Avatar answered Sep 24 '22 06:09

Jeffy