Sunday, March 13, 2016

Re: How can I delete all the ; in column mode? or how can I alignment the semicolons ?

On 13.03.16 19:54, Yang Luo wrote:
> input i_start_addr ;
> input num_pad_y ;
> input i_en ;
> input i_sram_ren0 ;
> input i_sram_raddr0 ;
> input i_wdata0 ;
...

With the cursor before the first such line,

.,$s/ *;$//

will delete any ';' at the end of lines, plus the immediately preceding
spaces, to the end of the file. To keep the spaces, omit the " *".

Alignment is trickier, and can vary depending on your tabstop setting.
You could set tabstop=15, if i_sram_raddr0 is the longest column-two
word, and substitute all space sequences with a single tab, then the ';'
will be aligned:

:set noexpandtab
:set tabstop=15
:.,$s/ */\t/g

That works here, on your lines, at the cost of greater spacing between
the first two columns as well. That could be reduced subsequently, if
sufficiently important.

The " *" idiom for "any non-zero number of spaces" can be expressed in
more standardised regex if sufficient Vim "magic" is turned on:

:.,$s/\v +/\t/g

I.e. " +" is "any non-zero number of spaces" in its simplest form.
Vim fails at that, by defaulting to obsolete BRE, rather than modern ERE.

Erik

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