Thursday, September 20, 2018

Re: What is the quickes way to delete spaces in front of each line?

On 09/19/2018 11:36 AM, Tim Chase wrote:
> On 2018-09-19 07:53, Igor Forca wrote:
>> I lot of times I have text something like:
>>
>> Sample:
>> ----Lorem ipsum dolor sit amet,
>> --consectetur adipiscing elit,
>> --------sed do eiusmod tempor
>> ---incididunt ut labore et dolore
>> ---magna aliqua.
>>
>> Note: Characters "-" symbolizes spaces.
>>
>> I need to delete spaces in as quicker way as possible.

> If you don't have to manually select which lines should be
> de-dented, you can also use
>
> :%le
>
> which uses the :left command to remove all leading space. It works
> with any range
>
> :10,20le
>
> or the visual selection
>
> :'<,'>le

Adding to Tim's suggestion: if you are going to change the
indentation on the entire paragraph, then ``vip`` is an easy way
to select the lines of interest without counting; then typing
``:%le`` will automatically use the visual range because Vim
will insert the line range ``'<,'>`` for you.

Tim continued:
> Alternatively, you can select a range with visual mode and use
> the "<" command with a ridiculously large prefix-count like
> "99<" to dedent the selected rows by 99 levels of 'shiftwidth'

Similarly, you can ``vip`` followed by ``99<`` to use this
second method on a paragraph.

I find that text objects such as ``ip`` (inner paragraph) come
in handy very often, saving me from trying to count lines or
from starting visual selection mode and moving down a line at a
time or whatever.  It's another tool in the toolbox that I use
frequently.  ``:help text-objects`` for more details.

Michael Henry

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: