Saturday, March 12, 2016

Re: quickly replace in normal mode

On 2016-03-11, Yang Luo wrote:
> I'm a vim newbie.
> for example this code block:
> ///////////////////////////////////////////////////
> wire [3:0] w_buff_length;//0--15
> always @(posedge clk or negedge rst_n)
> if (!rst_n) begin
> for(i=0; i< w_buff_length; i=i+1)s_data_buff[i] <= #1 {BIT_WIDTH{1'd0}};
> end
> else begin
> s_data_buff[0] <= #1 i_data;
> for(i=0; i< w_buff_length-1;i=i+1)s_data_buff[i+1] <= #1 s_data_buff[i];
> end
> /////////////////////////////////////////////////
> I want to replace w_buff_length with BUFF_LENGTH. I know hit *,
> and do :%s//BUFF_LENGTH/g can get it? Is there another way do not
> into command mode?

What I usually do in such cases, using your example, is:

1. Move cursor over w_buff_length
2. Hit *
3. Type cwBUFF_LENGTH
and hit Esc
4. Hit n
to find the next match
5. Hit .
to repeat the cw command
6. Repeat from step #4 until done

I usually keep my right index finger on the 'n' and my right ring
finger on the '.' and just alternate those two keys, sometimes
skipping the '.' if I don't want to change that particular match.

Regards,
Gary

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