There is a text file like that
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
mail:x:8:12:mail:/var/spool/mail:/bin/false
ftp:x:14:11:ftp:/srv/ftp:/bin/false
http:x:33:33:http:/srv/http:/bin/false
How to replace in VI all characters in strings 2-4 from 2nd to 5th to 'X'?
UPD: it's smth like: :2,4s//X/g I guess I need a regular expression
UPD2: :2,4s/^\(.\)...\|^$/\1XXX/ | 2,4s/^$/ XXX/
Vim only
Try this command:
Where:
2,4
is forin strings 2-4
\%2c...
is forfrom 2nd to 5th
XXX
is forto 'X'
Both Vim and Vi
As Vi doesn't have \%c, this command should be used instead:
Resources
:help :range
:help /ordinary-atom