I want to move a line by 4 bytes using vi editor. What command should I use?
I tried ">>" and it does move but it moves by 8 bytes..
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
8 spaces, from
'shiftwidth' 'sw' number (default 8) local to buffer Number of spaces to use for each step of (auto)indent. Used for 'cindent', >>, <<, etc.
So you should set
Add above line to
.exrc file to make it persistence.
In normal mode, type
4I then press space and then escape.
This will insert 4 spaces at the beginning of the line and move the line to the right. I assume this is what you want, since you mentioned that >> almost works for you.
When you are familiar with sed, you can also try sed-like commands. Suppose you just added an if statement and want to indent the lines until the next }. Then try
:.,/}/-1 s/^/ /