Thursday, August 16, 2018

Re: how can I replace two lines into one line

On 2018-08-16 04:54, Sand Glass wrote:
> > > I have many files, each file have the code block:
> > > #########
> > > `define DLY \
> > > 1
> > > ##########
> > >
> > > I want to change it to:
> > > #########
> > > `define DLY 1
> > > ##########
>
> How can I use it in all files(open the files into buffer?)?
> I try to use
> :args *.v
> :argdo :g/^`define/norm JXX | update

The issue comes from everything after "norm" being treated like a
normal-mode command so that's "Join, delete the first two characters,
space (go forward one character), pipe (go to column 0), space (go
forward one character), u (undo), p (paste), dat (delete around a
tag), e (go to the end of a word).

You have a couple options. To use the method you were using, I'd
recommend

:set hidden
:argdo g/^`define/norm JXX

then, after checking that they're all like what you want, issue

:wall

There are a number of other alternatives but this is what I would
have done as it's a bit more robust in the event of weird spacing
between the "define" and whatever comes after.

:argdo %s/^`define\>\zs\s*\\\n\s*/ /|up

-tim



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