Live data from Hacker News

A Vim Guide for Advanced Users

thevaluable.dev

151–160 of 179 posts

Re: A Vim Guide for Advanced Users

#151
post #5

The article mentions ”gn” in passing, but it doesn’t give it enough credit: this is an enormously useful motion, almost more useful on its own than the rest of the article. The thing that makes it golden is that it is a motion, and thus combined with a command, it is repeatable! So, like: 1. Search for something (either using / or *). 2. Type ”cgn” in Normal mode (i.e. change next search match) and replace what you s…

Yes, and here's my favorite vim trick I ever invented - you can do use this after changing a word.

What I mean is: if I'm on a (say) a variable name, and I change it with "cw", then realize I actually need to change it in a few more places, I can use a little shortcut to change it in those places, without even thinking of it beforehand.

The shortcut is:

  " Make . repeat the last "change word" command.
  nnoremap . :let @/=@"/cgn.
After any change command, just hit . to repeat it. You can thereafter hit "." to repeat again.

Re: A Vim Guide for Advanced Users

#152

Those commands may look useless at first sight, but combined can create powerful routines. As an example, my routine to refactor non-typesafe codebases. - Find the pattern that you want to replace (the last dot is for current dir) :grep -r 'pattern' . - Open the quickfix window and check if matches are correct :copen - Find and replace the entries of the quickfix list :cdo s/pattern/replacement/ | update

Thanks for sharing! It's always inspiring to see different workflows.

Re: A Vim Guide for Advanced Users

#153
post #87

The article mentions gI but that's 3 keystrokes (g, shift, i) when you can do 0i, and you probably want to know about 0 and i regardless, making the extra learning of gI unnecessary. Unfortunately this doesn't help anyone because it's not as if by deleting gI from your memory you can more easily learn something else, but perhaps it's helpful for a future guide writer or perhaps someone knows why gI is useful. Edit: T…

[deleted]

Re: A Vim Guide for Advanced Users

#154
post #83
post #19

Practical vim by Drew Neil is hands down the best vim learning resource out there. Nothing even comes close.

Anyone looking to pick this up: I found the best way to consume it is to grab a couple tips at a time (it’s structured as a “recipe book”) and incorporate them into your workflow. For example, try Netrw for a week, then another week try out folds. You don’t have to read it cover to cover to get the full benefit of it.

It looks like a really good way to take the most out of these recipe resources. Thanks for that!

Re: A Vim Guide for Advanced Users

#155

This was a really nice refresher and I learned a few new cool tricks (like gx). I'm a bit surprised that the 'u' flag for sort wasn't mentioned. That's the most useful one in my mind and I use it almost every time.

... I forgot it :D

I'll fix that. Thanks to point it out :)

Re: A Vim Guide for Advanced Users

#156
post #110

The number increment example doesn't seem to work for me. It says to start with this: 1. a 1. b 1. c The post says to "select in VISUAL mode the last two lines and hit `g CTRL+a`". So I guess with shift+v select the bottom two lines, and then I hit g, space, and Ctrl+a. I get: 1. a 2. b 2. c The post says that the last line should now start with 3 instead of 1, or in my case 2. The behavior is the same as when omitti…

mmm sorry for that, maybe I should review the way I'm displaying the different keystrokes.

Re: A Vim Guide for Advanced Users

#157
post #119

Earlier quoted context omitted.

It seems to work in both visual block mode and visual line mode for me, for what it's worth. (When not pressing space as mentioned in another reply.)

Huh, learn something new everyday. Thanks!

That was a good point though, I should precise that it works for visual line and visual block :) thanks for that!

Re: A Vim Guide for Advanced Users

#160

Everyone who uses Vim is an advanced user. The rest of us have to be content learning how to get back out of it without closing the terminal.

This question of what mean "intermediate", "advanced", "expert", or "master of the universe" is purely subjective to me. I've named these articles like I did to create some sort of progression, that's all.

So yes, I think you're right, like everybody :D

Post reply on HN