Saturday, January 21, 2012

Re: Shift column right by spaces?

* Tim Chase <vim@tim.thechases.com> [120121 08:41]:
> >>I would like to be able to move a column right by an arbitrary
> >>numbers of spaces, regardless of the value of `shiftwidth'.
> >
> >>Is that possible?
> >
> >many ways -- probably the simplest:
> >
> > - position the cursor at the left/top of the column you want
> > to move
> > - press ctrl-v to enter visual mode
> > - cursor down with the relevant motion command however long
> > your column is
>
> > - press I
> > - enter as many spaces as you want
>
> Or, enter a count for the number of spaces, press "I", insert one
> space and hit <ESC>.
>
> > - press ESC and the rest of the lines will get their spaces
>
>
> If the column is delimited rather than at a particular character
> offset, you can use (assuming a "," as the delimiter here)
>
> :%s/^\%([^,]*,\)\{5}\zs/\=repeat(' ', 10)
>
> where "5" is the number of columns to precede the insertion, and
> "10" is the number of spaces to insert. Similarly, one could use
> \%20c or \%20v as the search target for inserting N spaces.
>
> As SC said, lots of options :)
Thank you tim and sc. Works like a charm!
cheers
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: