On Wed, Jul 2, 2014 at 8:31 AM, Arup Rakshit <aruprakshit@rocketmail.com> wrote:
Hi Suppose,I have below data :describe ".employee_learning" dolet(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }let(:user1) { FactoryGirl.create(:user, gender: 'f') }endOnly first line I wrote.. then I did Shift + v, then yanked and then 7p. These many action created the above all similar lines. Now I am looking for a trick, so that I can make all user1(s), in one shot like user1-user7. Hope I am able tell you people about my expectation :-) Is this really possible ? or manually *r* command is the only trick to replace each 1 to 2,3,4 increasing order ?
There are many ways you can do this.
function! Increment()
let g:S=g:S+1
return g:S
endfunction
" For example, if you had a file with text like this: "(8 hours)"
" and you want to sum up the number of hours you can do the following:
:let g:S=0 "In global variable S we later find the result
" Then perform a substitute command:
" :%s/(user\zs1)/\=Increment(submatch(0))/g
The above is untested.
The way I usually do this is just with some of the very useful plugins around though.
I use this one mainly:
" VisInc - Visually Increment numbers/dates/days
Visually select the 1 for as many lines as you want (using CTRL-V) and hit
:I
Which is far easier than the above.
HTH,
David
--
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