r/programming • • May 23 '17

Stack Overflow: Helping One Million Developers Exit Vim

https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/
9.2k Upvotes

1.1k comments sorted by

View all comments

Show parent comment

1

u/bart2019 May 24 '17

Annoyances? How about this one.

When you press "a" to append on the current line, it doesn't move the cursor at the end of the line. Instead, it moves it to the position of the last character, for example, on the last letter.

W...T...F...

2

u/michaelpaoli May 24 '17

Nothin' unexpected there, standard vi/nvi behavior,
a to append after the current cursor position
A to append at the end of the line

In general with vi/nvi standard behavior, uppercase does/impacts something bigger or more general than the otherwise similar lowercase,
e.g. b vs. B, e vs. E, h vs. H, l vs. L, r vs. R, s vs. S, u vs. U, w vs. W, etc. But that's just in general. There are also highly useful (often slight) exceptions/variations, e.g.: f vs. F vs. ^F (forward vs. backwards vs. screenful), i vs. I (before vs. before first non-whitespace on line (or beginning of line if no non-whitespace on line)), n vs. N (forward vs. backwards), o vs. O (below vs. above), p vs. P (after vs. before), t vs. T (forward vs. backwards), x vs. X (current vs. to left).

"slide" set I've used many times for vi training presentations:
vi - basic introduction through advanced tips and "tricks" (works best along with the verbal presentation and fair number of quick demonstrations along the way, and some other handout materials - including ye olde vi (not vim!) quick reference card (best printed as double sided 11" x 8.5" tri-fold), and tutorial introduction:
Ex/Vi Quick Reference
An Introduction to Display Editing with Vi

1

u/superbad May 24 '17

Try "A" to append to the end of the line.

1

u/CaptainDickbag May 24 '17

Shift-$ to go to the end of a line. Shift-^ to go to the beginning. i for insert, a for append, o to insert a newline and edit.

1

u/MrHartreeFock May 24 '17

It's $ and ^, not shift+ those (that would be impossible on qwerty since it's required anyway, actually that is probably what gave you the wrong idea). If you want to see what I mean, change your layout to something that allows you to press ^ and $ without shift (eg azerty), you won't need shift at all then.

And they aren't opposites, 0 is the opposite of $, which brings you to the start or end of the line, ^ (or _) brings you to the first non-blank character of a line. g_ is the counterpart to ^

1

u/CaptainDickbag May 24 '17

Good points, thanks for the corrections.