Wednesday, September 19, 2018

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

On 09/19/2018 08:53 AM, Igor Forca wrote:
> I know there is ed command: 1,5s/^\s\+// but this is difficult to type
> quickly and requires a lot of thinking.

I don't know about difficult to type. I type things like that quite
frequently.

As for (a lot of) thinking, well, I find that most of vim's power
requires some thinking.

Unless I had a reason not to, I'd likely use %s/^\s\+// and apply it to
the entire buffer.

> Using some normal command and repeating j. would be much simpler to
> think and edit.

I find that repeating commands gets tedious quite quickly. Especially
if you're munging data. Hence why I like regular expressions like the
one above, or macros (possibly of the recursive variety). Why should I
have to mentally execute the test to see if I need to apply the action
to the line when I can have the computer do it for me. I just need to
tell the computer what to do.

IMHO regular expressions and and macros lend themselves to more
automation. It might even be possible to move the regular expression to
a (s)ed script.



--
Grant. . . .
unix || die

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

Post a Comment