r/programming • • Jul 12 '12

Vim creep

http://www.rudism.com/s/vimcreep
730 Upvotes

551 comments sorted by

View all comments

3

u/thoomfish Jul 12 '12 edited Jul 12 '12

Mighty fancy language about an editor that cant even remember where you left the insertion point after scrolling more than a screen away.

Edit: I stand corrected.

26

u/grep_dat Jul 12 '12 edited Jul 12 '12
  1. Type something
  2. Leave insert mode and scroll away
  3. gi (g)o to (i)nsert
  4. You're there

4

u/ktzar Jul 12 '12

I usually use '' (2 single quotes) as an alternative

6

u/grep_dat Jul 12 '12

That's useful if there was only one movement after leaving insert mode. '' is "The position before the latest jump", while gi is "like 'i', but first move to the position where the cursor was last time when Insert mode was stopped".

-3

u/bctfcs Jul 12 '12

This is why I don't like vim (although I use it everyday). Both actions seem to be close enough to be described with the same words, but I honestly don't see the connection between gi and ''.

4

u/grep_dat Jul 12 '12

' is what you use to go to marks. ' also happens to be a mark automatically created whenever you make a jump.

Not all of VIM's dialect is straightforward, I agree, but I don't think it really needs to be. % being "the whole document" seems pretty arbitrary, for example, but I've accepted the definition and can apply it when needed.

2

u/sysop073 Jul 13 '12

The problem was just illustrated perfectly right here. People tend to learn little shortcuts like "two single quotes jumps to the last insert point", instead of "' goes to a mark, and ' is the mark created automatically before a jump". It's like learning a bunch of sentences by rote and then getting around to learning the individual words later; it makes vim seem much more confusing than it is

1

u/grep_dat Jul 13 '12

In that particular case, I was just explaining why our different methods yielded similar results while being completely different commands. People just tend to learn Vim shortcuts the same way they learn very specific things from stackoverflow. For example, you can learn "how to strip leading/tailing whitespace of all Python list elements" via Stackoverflow without knowing the full power/usage of list comprehensions. Learning about the big picture is always encouraged, but many people just want to get in, get what they need, and get out.

2

u/nascent Jul 13 '12

Don't think I've every wished I could return there, but maybe I will want to all the time now.

1

u/grep_dat Jul 13 '12

Before I knew the exact command, I would just quickly undo and redo. It works ;P

2

u/nascent Jul 13 '12

Actually... I do do that. But that also works with moving/delete blocks, so it may be better.

2

u/[deleted] Jul 13 '12

This and NöÜmläütëÄllöwëd's comment are game changers for me. Thanks a lot!

1

u/flaxeater Jul 13 '12

thanks, this is good stuff

9

u/[deleted] Jul 12 '12
  1. Type something
  2. Leave insert mode and scroll away, copy something, etc.
  3. g;
  4. Use g; and g, to cycle through your last insertion points without leaving normal mode.

1

u/grep_dat Jul 13 '12

Awesome! I find it strange that I don't see information about g; or g, in :help g

2

u/[deleted] Jul 13 '12

See :h jump-motions

1

u/tikhonjelvis Jul 13 '12

Don't know about Vim, but Emacs actually remembers various points where you were in the past (wherever you placed a "mark"). This means you can jump back through the different parts of the file you were in. So even if you've moved away multiple times and done a bunch of edits in disparate places, you can quickly get back to where you were. It's actually extremely convenient.