Live data from Hacker News

Ask HN: What is your favorite lesser known VIM shortcut you can share

news.ycombinator.com

1–10 of 10 posts

Ask HN: What is your favorite lesser known VIM shortcut you can share

#1
:earlier 10m → Moves your buffer state 10 minutes earlier. :later 5m → Moves your buffer state 5 minutes later.

Why it's helpful: It acts like a time machine for your edits! If you regret changes but don’t want to undo manually, you can jump back in time.

You can also use it with changes, e.g., :earlier 5c (5 changes earlier).

Re: Ask HN: What is your favorite lesser known VIM shortcut you can share

#5
When I'm showing people the power of vim, I often use the `i` verb, like `ci"` and how it's not a "shortcut" but instead a sentence: change in quotes. If you start thinking about vim as a language instead of a collection of things to memorize, it becomes much easier, IMO.

Re: Ask HN: What is your favorite lesser known VIM shortcut you can share

#9
Maybe one lesser known is changing to visual mode within operation. A few examples (^ marks the cursor):

    one two three
                ^
'db' would leave letter "e" behind. But 'dvb' would include the "e" as well.

Another example, say we want to delete from "two" to "five".

    one
    two
     ^
    three
    four
    five
    six
'd/five' would leave a "t" as well as "five", but 'dV/five' would delete all necessary lines. This helps targeting lines without using relative line numbers.

Re: Ask HN: What is your favorite lesser known VIM shortcut you can share

#10
post #8

sometimes when I copy data into a file, I get some blank lines depending on how the data was formatted. This can often happen when copying from websites. I find this shortcut useful to delete all blank lines in a file :g/^$/d

To add to this, I would say :g in combination with :norm would be my choice.

Edit: Oh, also, since vim ships with xxd: xxd -r -p is a very useful thing to know.