On Nov 4, 5:33 pm, "Benjamin R. Haskell" <[email protected]> wrote: > On Thu, 4 Nov 2010, Benjamin R. Haskell wrote: > > On Thu, 4 Nov 2010, rameo wrote: > > >> I find myself often to align blocks of text and thought to create a > >> regex to remove all leading spaces in a block. > > >> p.e. > > >> text a > >> text b > >> text c > >> text d > > >> I would like to select a visual block around these 4 pieces of text > >> and remove all leading spaces, how can I do this? > >> - I can't use "^" because it aligns the block at the beginning of the > >> line. > > > :'<,'>s/\%V\s*// > > | | | \- \s* - zero or more spaces > > | | \- \%V - matches inside the visual area > > | \- s/// - substitution > > \- '<,'> = visual range > > > (Can't use \s\+ because it fails if the line contains, but doesn't > > start with, spaces). > > Also missed another corner case (spaces all through the visual block and > beyond): > > VV > text a > .. text b < > .text c < > text d > ^^ > > Before, the '.. text b' would become 'text b', instead of ' text > b'. Fixed by adding a trailing \%V, per suggestion at :help /\%V > > :'<,'>s/\%V\s*\%V// > > -- > Best, > Ben
It still moves the blocks at the right side of current block. (please see my previous message) Kind regards, Rameo -- 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
