Helmut Granda
Helmut Granda

Reputation: 4685

VIM: motion without jk and HardMode installed

I am enjoying hardmode and have definitely seen improvement. However the one item I am dealing with is selecting, moving, copying only two lines at the time. Current line +1 or -1.

Before hardmode the way I would select three lines of code in visual mode would be with the motion:

V2j

Since HardMode disables the "j" key what would be a good substitute to such move?

About HardMode:

Hard Mode is a plugin which disables the arrow keys, the hjkl keys, the page up/down keys, and a handful of other keys which allow one to rely on character-wise navigation. The philosophy behind Hard Mode is that you'll never master Vim's advanced motion and search functionality if you can fall back on the anti-pattern of fumbling around your code with the arrow keys.

https://github.com/wikitopian/hardmode

Upvotes: 1

Views: 872

Answers (2)

Ben
Ben

Reputation: 8905

I think I see the point of hardmode now, and you got an answer for how to select multiple lines in visual mode. That answer is correct, but maybe you don't need to select at all? You mentioned copying, or moving, a few lines. For that, try using counts with your yank/delete commands. Example, to copy 5 lines:

5yy

To delete 3 lines:

3dd

Upvotes: 1

sudo bangbang
sudo bangbang

Reputation: 28199

For me, HardMode is all about changing your mindset about how you move in vim. Really getting comfortable with text objects, searching etc.

In this case, you can just use 3V (3 <S-v>) to select 3 lines.

I'd urge you to learn some ex commands while you work in HardMode. Like use

:8,15d  " To delete lines from line no. 8 through 15
:8,15co .  "To copy range of lines 8 through 15 to current cursor position.

You can also use

:.+3  " To move down
:.-3  " To move up 3 lines

but then you'll be totally missing the point. Just use HardMode for what it's meant to be. Which is learn a few things in a constrained situation.

Upvotes: 3

Related Questions