2

given some text like

sadf_blahbalh_sdf
sadf_abc_zzz
asdf_yx_sdf

and I want to block select from the 'b' of blah down to the 'y' of yx and then, for every line extend the select to the _ using something like t_. But that will select till the _ on the line with yx. What I'd like is a jagged block select that will t_ per visual block line, so blahbalh, abc, and yx are all selected... is this possible? or a different approach?

so that if I then yank it and then do visual block select spaces between [ ] in the below example and paste...

[ ]
[ ]
[ ]

I'd end up with

[blahbalh]
[abc]
[yx]
1
  • 1
    Welcome to Vi and Vim! Unfortunately, the only jagged visual-blocks are ones that go to $ end-of-line. You might be able to automate this with a macro, though. Something like 0fbmaqqayt_ajmaq (excuse the formatting, there are backticks between q/a and _/a)—this would let you run @q to yank a particular block. You could add commands to move somewhere else and paste if you wanted too.
    – D. Ben Knoble
    Commented Jan 21, 2021 at 13:25

1 Answer 1

2

Plug-in vim-visual-multi implements multiple selections and it can do what you describe here. (It can even select multiple visual selections on lines that are not adjacent.)

See some examples on the README, also the Wiki has specific sections, for instance one on Motions and Modes. Once you install the plug-in, you can also find more documentation in Vim itself under :help visual-multi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.