Let's say I have this text with
| as my cursor:
<<<<<<< HEAD hi ======= hello ====== >>>>>> XXXX GGg|
Now, I'd like to select from >>>> to say second=== or line containing <<<< word. How do I do that?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
To answer your question in a more general way, you can combine the visual mode with any motion you use in normal mode. That means that you can use
w, etc but you can also use the search:
In your case with your cursor after
GGg you can start reverse search mode with ? and type
< in your search prompt. When you type Enter the end of your selection will end up on the last
< of the first line. (Maybe linewise visual selection can be useful for you here, it is triggered with Shift+v.
Note that if you already did the search you can use the motions
N to move your visual selection too.
You better be more clear|specific...
Now, I'd like to select from >>>> to say second===
or line containing <<<< word. How do I do that?
And if you want the answer to "How to end selection at an occurrence of a word?"
With the text
he|llo beautiful world
Where | is your cursor and you want to select till the end of the "beautiful"
v/ful/e which is
/fulsearch for "ful"
/emove cursor to the end of word found
I'd like to select from
>>>>to say second
?^====== and press enter.
n if you want to continue the selection to the first
or line containing
?^<<<<<< and press enter.
va>select :h a> block
a>is characterwise, need to convert to linewise.
Another way is to add
<> to :h 'matchpairs' :
Vstart visual linewise
^go to 1st
If there are
> in the body, add an
^ to search match for the most outside
=== part, use
?^=== to search backward, use
n to repeat last search.