Need a vim "hard mode" tutorial.

1,012 views
Skip to first unread message

DwigtArmyOfChampions

unread,
May 12, 2013, 8:11:09 PM5/12/13
to vim...@googlegroups.com
I've been struggling along with Vim's "hard mode" plugin that's supposed to train you to use the "good habits" instead of the "bad habits" that eventually will make you program better and faster. OK, I know what the "bad habits" are, since they've been disabled (hjkl, backspace, and a few other things), but I'm having a tough time figuring out what the "good habits" are. If you're not going to search, then are you pretty much always supposed to use Ctrl-u and Ctrl-d to navigate through your code, and then when you spot a line that needs changed, type :(line number)? Because that's pretty much the only way I've been able to move around. What if you're in visual mode and you therefore can't use the : to run a command to get to the line number you want the visual block to end on? Does this mean you should never use visual mode? I'm so confused. Help!

Tony Mechelynck

unread,
May 12, 2013, 8:52:06 PM5/12/13
to vim...@googlegroups.com
On 13/05/13 02:11, DwigtArmyOfChampions wrote:
> I've been struggling along with Vim's "hard mode" plugin that's supposed to train you to use the "good habits" instead of the "bad habits" that eventually will make you program better and faster. OK, I know what the "bad habits" are, since they've been disabled (hjkl, backspace, and a few other things), but I'm having a tough time figuring out what the "good habits" are. If you're not going to search, then are you pretty much always supposed to use Ctrl-u and Ctrl-d to navigate through your code, and then when you spot a line that needs changed, type :(line number)? Because that's pretty much the only way I've been able to move around. What if you're in visual mode and you therefore can't use the : to run a command to get to the line number you want the visual block to end on? Does this mean you should never use visual mode? I'm so confused. Help!
>

Vim is about Choice. Vim is about having several different ways (suiting
different people) to achieve the same results. If some plugin is
disabling a lot of keystrokes (including hjkl and Backspace, for
X-sake!) just to make you type the way *they* think is right, then
that's what is bad. Dogma runs contrary to all that is Vim (and to all
that is free-as-in-speech in general).

My 0.02 € advice: Junk that "hard mode" plugin.


Best regards,
Tony.
--
If all else fails, immortality can always be assured by spectacular
error.
-- John Kenneth Galbraith

Gary Johnson

unread,
May 13, 2013, 1:53:35 AM5/13/13
to vim...@googlegroups.com
On 2013-05-13, Tony Mechelynck wrote:

> Vim is about Choice. Vim is about having several different ways
> (suiting different people) to achieve the same results. If some
> plugin is disabling a lot of keystrokes (including hjkl and
> Backspace, for X-sake!) just to make you type the way *they* think is
> right, then that's what is bad. Dogma runs contrary to all that is
> Vim (and to all that is free-as-in-speech in general).
>
> My 0.02 € advice: Junk that "hard mode" plugin.

Well said.

Regards,
Gary

Asis Hallab

unread,
May 13, 2013, 4:05:15 AM5/13/13
to vim...@googlegroups.com
Dear Vimers,

2013/5/13 DwigtArmyOfChampions <dwightarmy...@hotmail.com>:
> If you're not going to search, then are you pretty much always supposed to use Ctrl-u and Ctrl-d to navigate through your code, and then when you spot a line that needs changed, type :(line number)?

I have been facing the very same problem. For me Vim is about doing
the job of text editing efficiently. So getting to the place you want
to edit should be fast and easy. In spite of all the different
available movement commands I frequently find myself thinking, that in
a particular situation I might had gotten to the place I want to edit
faster using the mouse. After all searching or jumping to a a line
number easily require four to five key strokes.

> Because that's pretty much the only way I've been able to move around. What if you're in visual mode and you therefore can't use the : to run a command to get to the line number you want the visual block to end on?

You can use G<line_number> to get to the line you spotted. This works
in visual mode, too.
:h G

I would very much like to read about expert Vim users most used
movement commands and get more efficient in getting to the point I
want to edit.

Cheers!

Rostislav Svoboda

unread,
May 13, 2013, 5:15:26 AM5/13/13
to vim...@googlegroups.com
Forcing one hand to move to that dark Escape corner far far up left
and forcing the right hand to move on the hjkl home row is a damn bad
habit when all you need is "two lines down, one column right".
My hands NEVER rest on the home rows! When not actively typing either
I hold a pen/drink/phone/mouse/nose/whatever or my hands rest on edges
of the keyboard or the arrows keys because it is much more comfortable
and relaxing to keep them there.
The "hjkl" is a myth! A fairy story. It’s what parents tell their kids
at night if they want them to grow up to be administrative assistants.

Erik Christiansen

unread,
May 13, 2013, 5:21:43 AM5/13/13
to vim...@googlegroups.com
On 13.05.13 10:05, Asis Hallab wrote:
> I have been facing the very same problem. For me Vim is about doing
> the job of text editing efficiently. So getting to the place you want
> to edit should be fast and easy. In spite of all the different
> available movement commands I frequently find myself thinking, that in
> a particular situation I might had gotten to the place I want to edit
> faster using the mouse. After all searching or jumping to a a line
> number easily require four to five key strokes.

Yes, searching, e.g. /Gob to go to "Goblin", many lines away, can work,
but you have to whack 'n' if the search finds another before the one
you're after.

For me, a long-time non-expert user, it is convenient to use H,M, or L
to instantly reach the approximate page portion of interest¹. A quick
visual guesstimate, and a 7+ or 5- gets close enough for an up/down
arrow to bring me to the target line. To reach the desired word, I
prefer to use 7W or 6B, because the eye does not readily estimate minor
word components. Using 0/^ or $ first, allows word count estimation
from the nearest end of the line, giving more frequent first-guess hits.
If the brain is tiring, then a few Ws are quick to peck out, rather than
guess counts, and work especially well with long Words, e.g. pathnames.
Oh, and I find ge, to go to the end of the previous word to be not as
quick, especially after a few b/B, as one extra b/B, followed by an e/E.

Resorting to the mouse would definitely be slower.

When working with paragraphs, such as this post, my fingers
automatically resort to } and {, since H,M, and L would take me out of
the couple of paragraphs being hammered into shape at any moment. Within
the paragraphs, '(' and ')' can be a quick way around. It is faster to
hit the same key 3 times, rather than 3 separate keys, or find the
mouse.

One thing which works for me is to have vim exit insert mode on up/down
arrow, but not l/r. (Yup, I have no use for that jkl and whatever
nonsense - because I'll never be a touch typist, despite nearly three
decades as a programmer.)

But it doesn't all have to be fast. When thinking about how the next
paragraph should start, just plodding back down after an intra-paragraph
edit, with down-arrows, reduces the wetware processing load, possibly
making for better content.

Going back to review this before posting, I'm reminded that Page-Up and
Page-Down work fine in vim. Or ^b and ^f, if you haven't remapped them.
(I'm experimenting with using ^b for ":bu ", to save keystrokes when I'm
working with thirty or forty buffers open, and zapping between them
several times per minute.)

This isn't quite motion, but ^d in insert mode undoes one tab of indent.
That can reasonably often save a few keystrokes, if autoindent is on, as
when hacking a bit of code.

But there's sure to be an FAQ or tutorial on the topic on the vim site
somewhere, I'd guess.

Erik

¹ I have set scrolloff=3, so H and L do not go to the page extremes.
That means it's not quite so far to the target line, allowing a better
guess for the line jump.

And ^o is the quickest and surest way back to my second paragraph,
after adding this footnote, while G{ took me here from there, across
40 lines, in two keystrokes. (The { is to come back before the sig.)

--
Maybe there should be more of this worldwide?:
"Our milk's the closest thing that you can get to putting your jug in the vat,"
Pyengana's Jon Healey, commenting on the growing trend of farmer-marketed milk,
in response to the unsustainable $1/L retailing of milk by big multinationals.
http://www.abc.net.au/news/2013-05-10/price-war-drives-demand-for-farmhouse-milk/4681996

Erik Christiansen

unread,
May 13, 2013, 5:47:33 AM5/13/13
to vim...@googlegroups.com
On 13.05.13 11:15, Rostislav Svoboda wrote:
> Forcing one hand to move to that dark Escape corner far far up left
> and forcing the right hand to move on the hjkl home row is a damn bad
> habit when all you need is "two lines down, one column right".

To help reduce the hand travel, I've moved escape down onto the CapsLock
key. It's closer and bigger. Even on laptops it can be whacked with
little hand motion.

> My hands NEVER rest on the home rows! When not actively typing either
> I hold a pen/drink/phone/mouse/nose/whatever or my hands rest on edges
> of the keyboard or the arrows keys because it is much more comfortable
> and relaxing to keep them there.
> The "hjkl" is a myth! A fairy story. It’s what parents tell their kids
> at night if they want them to grow up to be administrative assistants.

:-)) Couldn't agree more.

Erik

--
Anyone who believes exponential growth can go on forever in a finite world is
either a madman or an economist.   - Kenneth Boulding, economist

Tim Chase

unread,
May 13, 2013, 6:58:44 AM5/13/13
to vim...@googlegroups.com, dva...@internode.on.net
On 2013-05-13 19:21, Erik Christiansen wrote:
> To reach the desired word, I prefer to use 7W or 6B,
> because the eye does not readily estimate minor word
> components. Using 0/^ or $ first, allows word count
> estimation from the nearest end of the line, giving more
> frequent first-guess hits.

Sounds like you could benefit from t/T/f/F/,/; which I use ALL THE
TIME for horizontal navigation. I find it pretty easy to eyeball an
infrequent letter and then type "2fj" to jump to the 2nd "j" after my
cursor. If I miss, it's just a ";" ("not far enough") or "," ("too
far") to continue in the corresponding direction.

I use them so often that it baffles me when I see people remap "," to
be their map-leader, throwing away such fabulous functionality. :-)

-tim



AK

unread,
May 13, 2013, 8:06:15 AM5/13/13
to vim...@googlegroups.com
I made a small modification to Vim source that shows line number from
top of screen instead of from top of file and I've set up two shortucts
for navigation:

<N>space - goes to Nth line from top of screen
space - toggles between 3 positions on current line: 25%, 50% and 75%

The last shortcut uses a small function I wrote.

These two commands that use the same key work much better (for me) than
anything Vim has available built-in.

I thought relative-number mode would be great but in practice it doesn't
seem to work that well. First of all, I don't always remember if I'm
above the line I need to go to or below. This is annoying, because the
action of 'go to this line' is so common it really NEEDS to be a
single-action process, i.e. look up the line, use a single command to go
there.

With relative-number, first you need to make sure if you're above or
below and then use j or k. And it's easy to make a mistake. This is
simply too much overhead for such a simple action.

In addition, a common case is that you might want to go back and forth
between a couple of places in current screen, then it's very helpful if
you just need to remember 2 absolute line locations, e.g. 5 and 25 and
go there directly without having to look them up, irrespective of
current line location.

-ak

Erik Christiansen

unread,
May 13, 2013, 8:11:17 AM5/13/13
to vim...@googlegroups.com
On 13.05.13 05:58, Tim Chase wrote:
> Sounds like you could benefit from t/T/f/F/,/; which I use ALL THE
> TIME for horizontal navigation. I find it pretty easy to eyeball an
> infrequent letter and then type "2fj" to jump to the 2nd "j" after my
> cursor.

I have tried that, particularly in recent times, but my eyesight is not
what it was when I was younger. I miss too many intervening characters,
except in the case of ','. Also, as soon as I use a search my bones
insist that it should work across line boundaries. That t/T/f/F do not
is so frustrating that I generally use it once or twice in a session,
then shift to '/', to reduce the swearing.

Oddly though, I'm increasingly partial to using especially "cf".

> If I miss, it's just a ";" ("not far enough") or "," ("too
> far") to continue in the corresponding direction.

That would help a lot. I might try changing my habits.

> I use them so often that it baffles me when I see people remap "," to
> be their map-leader, throwing away such fabulous functionality. :-)

And once we're chained to a mapping by habit, it's hard to change.

Erik

--
Oregano, n.:
The ancient Italian art of pizza folding.

guyo...@gmail.com

unread,
May 13, 2013, 5:01:35 AM5/13/13
to vim...@googlegroups.com

-----Message d'origine-----
De: Asis Hallab
Envoyé: 13/05/2013, 10:05
A: vim...@googlegroups.com
Objet: Re: Need a vim "hard mode" tutorial.


Dear Vimers,

2013/5/13 DwigtArmyOfChampions <dwightarmy...@hotmail.com>:
> If you're not going to search, then are you pretty much always supposed to use Ctrl-u and Ctrl-d to navigate through your code, and then when you spot a line that needs changed, type :(line number)?

I have been facing the very same problem. For me Vim is about doing
the job of text editing efficiently. So getting to the place you want
to edit should be fast and easy. In spite of all the different
available movement commands I frequently find myself thinking, that in
a particular situation I might had gotten to the place I want to edit
faster using the mouse. After all searching or jumping to a a line
number easily require four to five key strokes.

> Because that's pretty much the only way I've been able to move around. What if you're in visual mode and you therefore can't use the : to run a command to get to the line number you want the visual block to end on?

You can use G<line_number> to get to the line you spotted. This works
in visual mode, too.
:h G

I would very much like to read about expert Vim users most used
movement commands and get more efficient in getting to the point I
want to edit.

Cheers!

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

---------------------------------
I was asking myself the very same question a while ago and here is one of the links I found:
http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim?rq=1

the top voted answer in this link is very great at make you feel the power of Vim. It's very detailed and gives some good tricks.

After that I bought Drew Neil's book "Practical Vim: edit text at the speed of thought". If you like books this one is realy great. Otherwise look for screencasts of vim on internet, they give usefull advices.

I hope it will be usefull to you.

Regards
Damien

Alice Wonder

unread,
May 13, 2013, 5:57:49 AM5/13/13
to vim...@googlegroups.com
On Sun, 2013-05-12 at 17:11 -0700, DwigtArmyOfChampions wrote:
> OK, I know what the "bad habits" are, since they've been disabled (hjkl, backspace, and a few other things)

I didn't know those were bad habits. I've been using those keys for
movement ever since dad let me play rogue back when I was a young one
and his acoustic coupler made me the envy of the neighborhood.

They work just fine for me when moving around inside a file, bad habit
or not.

Tim Chase

unread,
May 13, 2013, 1:30:07 PM5/13/13
to vim...@googlegroups.com, alice...@shastaherps.org
On 2013-05-13 02:57, Alice Wonder wrote:
> On Sun, 2013-05-12 at 17:11 -0700, DwigtArmyOfChampions wrote:
> > OK, I know what the "bad habits" are, since they've been disabled
> > (hjkl, backspace, and a few other things)
>
> I didn't know those were bad habits.

I think it's not that they're bad habits, just that it's easy to use
them in ways that occlude better/faster ways. Rather than pressing
"h" 20 times, you might mean

- "I want to go 20 characters to the left", in which case it would
benefit you to learn "20h"

- "I want to go to column 18", in which case using "18|" will jump
you right there

- "I want to go back a couple words and position myself at the
beginning of a word", in which case using "b" or "B" a couple
times, or prefixing it with a count may be a better way to move

- "I want to move the cursor to right after the opening paren", in
which case using "T(" is pretty targeted.

I could likely count on one hand the number of times in the past year
that I've used h/l for left/right navigation, and it's almost never
more than one or two presses. Vertical navigation with j/k tends to
be more frequent for me, as I often use that to mark my line when I'm
reading/reviewing.

-tim




tooth pik

unread,
May 13, 2013, 2:04:57 PM5/13/13
to vim...@googlegroups.com
with a nice fast keyboard repeat rate and a nice short keyboard delay,
I never feel the need to horizontally locate -- consider me a loud and
proud baffling remapper of ',' to mapleader and my fav, ';' to ':'

who wants to count 'j's anyway?

sc

Tim Chase

unread,
May 13, 2013, 2:35:24 PM5/13/13
to vim...@googlegroups.com, guyo...@gmail.com
On 2013-05-13 11:01, guyo...@gmail.com wrote:
> You can use G<line_number> to get to the line you spotted.

Just for the record, that's <line_number>G :-)

> I would very much like to read about expert Vim users most used
> movement commands and get more efficient in getting to the point I
> want to edit.
...
> After that I bought Drew Neil's book "Practical Vim: edit text at
> the speed of thought".

[disclaimer: I was one of the technical reviewers on Drew's text]
It really is a good book for picking up tips on how to think in Vim's
language, looking at things you do repeatedly and finding better ways
to do them.

-tim



Tony Mechelynck

unread,
May 14, 2013, 12:27:43 AM5/14/13
to vim...@googlegroups.com
On 13/05/13 10:05, Asis Hallab wrote:
> Dear Vimers,
>
> [...] For me Vim is about doing
> the job of text editing efficiently. So getting to the place you want
> to edit should be fast and easy. In spite of all the different
> available movement commands I frequently find myself thinking, that in
> a particular situation I might had gotten to the place I want to edit
> faster using the mouse. After all searching or jumping to a a line
> number easily require four to five key strokes.

Well, you know what? Vim lets you use your mouse too, at least if it can
get your mouse clicks, and that means in all versions of gvim and in
many versions of Console Vim. Depending on the terminal, you may need to
have the appropriate mouse feature compiled-in, for instance +mouse_gpm
for the Linux text console with the gpm mouse helper running.

Assuming of course that you aren't dead set on using Vim with only the
keyboard.

Of course, moving your hand from the keyboard to the mouse and back may
take some time, even more time than moving it to <Esc> and back
(mentioned somewhere else in this post) but not necessarily very much
more than moving from the main part of the keyboard to the numeric
keypad and back. Well, one advantage is that if you see the place where
you want to go, which seems to be, let's say, "between seven and twelve
lines down and between forty and sixty columns right" from where you are
now, going there by mouse requires no complex thinking (which would also
take time).

[...]
>
> Cheers!
>

Best regards,
Tony.
--
We call our dog Egypt, because in every room he leaves a pyramid.

Tony Mechelynck

unread,
May 14, 2013, 2:13:26 AM5/14/13
to vim...@googlegroups.com
On 13/05/13 14:11, Erik Christiansen wrote:
> On 13.05.13 05:58, Tim Chase wrote:
>> Sounds like you could benefit from t/T/f/F/,/; which I use ALL THE
>> TIME for horizontal navigation. I find it pretty easy to eyeball an
>> infrequent letter and then type "2fj" to jump to the 2nd "j" after my
>> cursor.
>
> I have tried that, particularly in recent times, but my eyesight is not
> what it was when I was younger. I miss too many intervening characters,
> except in the case of ','. Also, as soon as I use a search my bones
> insist that it should work across line boundaries. That t/T/f/F do not
> is so frustrating that I generally use it once or twice in a session,
> then shift to '/', to reduce the swearing.

I notice that I use /? and tTfF for different purposes: To get at the
next "ship" (not "hardship" or "shipping") in the page I'll use
/\<ship\> but to copy to the clipboard from the cursor to just before
the next < on the line I'll use "+yt<

IOW I don't think of tTfF as searches but as (horizontal) moves, similar
to b and e (begin/end of word), 0 and $ (begin/end of line), etc. (And
BTW for purists, I know that the exact converse of $ is not 0 but
<Home>.) It's just that in the case of tTfF the destination of the move
is not hardcoded, it's given as an argument.

>
> Oddly though, I'm increasingly partial to using especially "cf".
>
>> If I miss, it's just a ";" ("not far enough") or "," ("too
>> far") to continue in the corresponding direction.
>
> That would help a lot. I might try changing my habits.
>
>> I use them so often that it baffles me when I see people remap "," to
>> be their map-leader, throwing away such fabulous functionality. :-)

There are really few unused key bindings in Vim. For my own mappings, I
try to err on the side of safety, using only <F2> to <F9>, <F11>, <F12>
and <S-F1> to <S-F12> for [the first key of] the {lhs} unless I
intentionally want to override some known binding. Oh, and also, in
Normal mode, non-ASCII keys like é§èçàùµ² (all of which exist as
unshifted keys on my keyboard) and £ (Shift-µ) or ³ (Shift-²). If
hard-pressed I might think of letters with circumflex or
umlaut/diaeresis (both of which have been present as a dead key,
respectively with and without Shift, on all AZERTY keyboards since the
times of typewriters).

>
> And once we're chained to a mapping by habit, it's hard to change.

:-)

>
> Erik
>

Best regards,
Tony.
--
Stop searching. Happiness is right next to you. Now, if they'd only
take a bath ...

Reply all
Reply to author
Forward
0 new messages