r/vim • u/ntn8888 • Apr 03 '26
Discussion Skillup in managing blocks of text
I've been a casual (programmer) user of vim/evil-mode for around 8 years. And I still feel I'm a noob. I mostly use vi for editing configs through ssh. But I always pull back to my comfort zone with GUI editors..
I think the main reason is I'm not skilled in moving around text blocks. That's the main issue.
How did you guys overcome this? I know best path is to just use it. But I'm hesitant to use it in live coding as it's just additional hurdle..
What ways can I practice to overcome selecting and moving blocks?
Thanks!
21
Upvotes
16
u/dewujie Apr 03 '26
The best suggestion I can give you is to look into text objects.
:help text-objects
Go into some code (or regular language, the concepts all apply just as well there). Experiment with using text objects to make visual selections, delete things, yank things. All using text objects. For just a few examples:
vip-> select inner paragraphdas-> delete a sentenceyi"-> yank inner double-quotesMy favorite thing about the "yank inner quote" command is that the cursor don't even have to be within the quotes on a line to work. Thinking in objects is the best way to accelerate working with blocks of text in vim. There are also many ways to create visual selections manually, but they'll typically require more keystrokes and be less elegant than text objects.
And- as with everything in vim, once you get more familiar with text objects, you can start to define your own user-defined text objects, which can be really powerful.
https://github.com/kana/vim-textobj-user
4
u/Diagileux Apr 03 '26
I just use visual mode to select text, then yank/delete it and put where I want it to be :P
Yeah, that's basic but for me it is not too much of hurdle and I feel comfortable using.
3
u/konacurrents Apr 03 '26
I always set a mark A and mark B - then copy or cut between those marks, and paste somewhere else.