calling to vimming geeks

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

calling to vimming geeks

Aditya Kher

folks,
what is the best way to write something like follows?

foo somename_0 {
      text_that_doesnt_change_A;
     boo somename_Data_0 {
      text_that_doesnt_change_B;
      text_that_doesnt_change_C;
      }


foo somename_1 {
      text_that_doesnt_change_A;
      boo somename_Data_1 {
      text_that_doesnt_change_B;
      text_that_doesnt_change_C;
      }


and so on till....


foo somename_1023 {
      text_that_doesnt_change_A;
     boo somename_Data_1023 {
      text_that_doesnt_change_B;
      text_that_doesnt_change_C;
      }




--
Aditya Kher
http://kher.org

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: calling to vimming geeks

Kev-13

Aditya Kher wrote:

> folks,
> what is the best way to write something like follows?
>
> foo somename_0 {
>       text_that_doesnt_change_A;
>      boo somename_Data_0 {
>       text_that_doesnt_change_B;
>       text_that_doesnt_change_C;
>       }
>
>
> foo somename_1 {
>       text_that_doesnt_change_A;
>       boo somename_Data_1 {
>       text_that_doesnt_change_B;
>       text_that_doesnt_change_C;
>       }
>
>
> and so on till....
>
>
> foo somename_1023 {
>       text_that_doesnt_change_A;
>      boo somename_Data_1023 {
>       text_that_doesnt_change_B;
>       text_that_doesnt_change_C;
>       }
>
>
>
>
>  

I record keystrokes to a register and run with a count:
qfV6jy6jp<c-a>2j<c-a>2kq1022@f

Broken down:

1) qf  # begin recording
2) V # visually select the entire first line
3) 6j # extend visual selection down to 1 line past the code
4) y # yank the selection
5) 6j # goto the blank line past the code
6) p # paste the yanked text
7) <C-a> # increment the number on the first line of the yanked text
8) 2j # go down 2 lines
9) <C-a> # increment the number on the 3rd line of yanked text
10) 2k # goto the first line of the yanked text
11) q # stop recording
12) 1022@f # give the keyboard macro a count and run.

Kevin



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: calling to vimming geeks

Aditya Kher

that does it!!
I knew <CTRL>A increments but I did not know it increments the number
on a *given* line... should've RTFM...
sorry for spamming vim-lovers...
-aditya

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: calling to vimming geeks

Sartak

On 8/3/07, Aditya Kher <[hidden email]> wrote:
>
> that does it!!
> I knew <CTRL>A increments but I did not know it increments the number
> on a *given* line... should've RTFM...
> sorry for spamming vim-lovers...
> -aditya

No worries about the "spam". It's a perfectly valid question, and I'm
sure you're not the only one who has learned from Kev's answer. Here's
another version:

yap}p^Ajj^Akk

1) qq   # begin recording
2) yap  # yank a "paragraph"  (one of these data structures)
3) }    # go to the end of the "paragraph"
4) p    # put the paragraph in
5) ^A   # increment
6) jj   # move down to the next something_N
7) ^A   # increment
8) kk   # move back to where the macro needs to start

It's unhappy that your programming language forces you to this length,
though! :)

Shawn M Moore

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---