2
value(val_1)
value(val_100)
value(val_10)

I want to select text between parentheses and do it for multiline, for one line I can use f(va( but I don't know how to select for 2 remaining lines.

EDIT (SOLUTIONS)

What I want to is to change text inside parentheses with unique text every line, firstly, I was thinking to select the text, delete it then change the text manually, @rosipov tell there is a plugin to do the selection part and it's great, but @romainl gave me another direction that works too.

f(ci(foo<Esc>jci(bar<Esc>jci(baz<Esc>

Adam
  • 67
  • 6

2 Answers2

2

Do you want to select this:

value([val_1])
value([val_100])
value([val_10])

or to select that:

value([val_1)]
[value(val_100)]
[value(val_10])

The first is unfortunately not doable. But depending on what you want to do with the selected text, change it for example, a reasonable approximation would be:

f(l<C-v>jj$cnew value)<Esc>

However I'm sure a lot of Vimmers would probably approach the problem with a substitution:

:,+2s/(.*/(new value)

The second is done simply with:

f(lv3/)h

or

f(ljjt)
romainl
  • 186,200
  • 21
  • 280
  • 313
  • Unfortunately I want the first one, I simply just want to select it, not search and replace, but thanks for answer it. – Adam Mar 28 '13 at 07:05
  • @Adam, unlike in other editors where it's the only way to act on some text, selecting something is often the least efficient way to go in Vim. Selecting some text is intrinsically useless: you *always* want to do something with what is selected. That's the part that matters. `select` + `movement` + `action` can often be shortened to `action` + `movement`. What actions you perform depend on what you want to do and, depending on the situation, may be "a lot" or "a few". Using visual selection systematically is way too generic and, often, a waste of keypresses. – romainl Mar 28 '13 at 07:50
  • You are right, I need to change the text inside parentheses with a unique text each line, maybe I can use regex but I don't have skill on it, that's why I'm asking to select, delete and change it manually, I know it's inefficient. – Adam Mar 28 '13 at 08:01
  • @Adam, the accepted answer doesn't give you what you want either. – romainl Mar 28 '13 at 08:01
  • Yes, but @rosipov gave me direction to easymotion plugin, I'm using it right now, so indirectly it answer my question. – Adam Mar 28 '13 at 08:05
  • @Adam, your question is actually very different from your actual goal: selecting anything is useless and, since you want different values on each line, multiline selection is even more useless. What you need is simply `f(ci(foojci(barjci(baz`. No need for a plugin, here. – romainl Mar 28 '13 at 08:05
  • I was thinking to select and delete it simultaneously, then write new text on it, but your last comment give another way, thanks and sorry not make myself clear. – Adam Mar 28 '13 at 08:15
1

You will probably be interested in EasyMotion plugin in this case: https://github.com/Lokaltog/vim-easymotion

With plugin it will be: f(vLeaderLeaderf)c

Or: LeaderLeaderf(avLeaderLeaderf)c

Where c is letter representing 3rd closing parentheses, a represents first opening p.

EDIT: Without plugin it is possible to do it by line number.

Assuming that you work with lines 1-3: f(v3Gf)

Where 3G stands for "go to line number 3", works in both visual and normal modes.

Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44
  • Thanks, I don't know there exist such plugin. Just for curiosity, is there a way without using any plugin? sometime I have access with just vanilla vim only. – Adam Mar 28 '13 at 04:21
  • @Adam Please see edit. You can also do something like `2` `j` after selecting first character to go to the right line. All regular moving commands apply. – Ruslan Osipov Mar 28 '13 at 04:42
  • Hmm, but is select all remaining line with 3G, when I just want select text in parentheses, in this case the word 'value' should not selected. – Adam Mar 28 '13 at 04:43
  • @Adam Oh, you mean selecting only text in the parentheses on all lines simultaneously? It's not possible in vanila vim, see this http://stackoverflow.com/questions/1608204/multiple-selections-in-vim – Ruslan Osipov Mar 28 '13 at 04:47