Live data from Hacker News

A Vim Guide for Advanced Users

thevaluable.dev

71–80 of 179 posts

Re: A Vim Guide for Advanced Users

#72
post #19

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

Drew Neil's Modern Vim is also wonderful. While it introduces a lot of plugins in an attempt to modernize the experience, it also includes some excellent notes on standard features(qf/sessions/etc).

I'll also note it covers both vim and neovim, with nice little asides explaining the differences where they matter.

Re: A Vim Guide for Advanced Users

#73
post #7
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…

Why is this preferable to :%s?

It allows you to use a full Turing machine rather than restricting yourself to a Finite State Machine.

Re: A Vim Guide for Advanced Users

#74

Nice, but still wondering if I should know vim since nano is enough for me :)

I recommend learning the basics. It's great being able to navigate around a file with the keyboard in ways other than arrow keys to move a line at a time. Stuff like hitting "%" to move between matching parenthesis, { and } to move between paragraphs, etc. And if you do any kind of development, the automatic indentation (and to indent and outdent ranges) are hugely useful. All of these are also things you can use in IDEs like VS Code with their vim modes.

The stuff in this article is pretty neat but (even after using vim for about 20 years) most of it doesn't click for me as easily. Eg I don't use marks; I wouldn't think ahead to leave a mark or remember afterward which letter I used for it. Kudos to people who can gain productivity by using this stuff, but I'd need something other than an explanation of what the commands do to be effective with it. I do at least try to use the quickfix stuff; that's a pretty big productivity boost over manually going to the right file and line to fix an error spotted by my compiler.

Re: A Vim Guide for Advanced Users

#75

Vim is getting more popular. Not just within vim, but outside vim! Practically every full-featured editor has a vi or vim mode, and when they say vi, usually they also mean vim. Things that have nothing to do with vim but are inspired by vim are even sprouting up! And apparently it's OK to name something based on vim: https://groups.google.com/g/vim_use/c/EnSMrx_rGg4/m/d_nVlmLQ... Edit: In Bram's reply he mentioned t…

I definitely agree that it’s getting more popular.

I use vim inside VS code as my main editor and love the experience. It was also an easy way to step into learning vim.

I also have a vim product with vim in the name (it’s practically the whole name) and haven’t had any sort of trademark issues.

Re: A Vim Guide for Advanced Users

#76
post #64

Earlier quoted context omitted.

The non-barbarian way to avoid counting characters when there's no convenient motion is visual mode. Hit v, then hit l until you've highlighted the part you want to change, then hit c to start changing it.

Oh I never thought about that either. Thank you.

I rarely actually do it because f and t motions, possibly with a number, can usually handle these cases. For example, c3tA to change up to but not including the third capital A after the current position

Re: A Vim Guide for Advanced Users

#77

Vim is getting more popular. Not just within vim, but outside vim! Practically every full-featured editor has a vi or vim mode, and when they say vi, usually they also mean vim. Things that have nothing to do with vim but are inspired by vim are even sprouting up! And apparently it's OK to name something based on vim: https://groups.google.com/g/vim_use/c/EnSMrx_rGg4/m/d_nVlmLQ... Edit: In Bram's reply he mentioned t…

I definitely agree that it’s getting more popular. I use vim inside VS code as my main editor and love the experience. It was also an easy way to step into learning vim. I also have a vim product with vim in the name (it’s practically the whole name) and haven’t had any sort of trademark issues.

Yeah, the current situation, with no registered trademark for vim the editor, seems to be great for everyone! Vim is popular enough that it's unlikely to be taken. However, someone is currently trying to claim Screen for a screen sharing product despite a screen sharing tool called screen(1) having been around for decades, so nothing is impossible.

Re: A Vim Guide for Advanced Users

#78
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…

Maybe you will like these little gems I came up with back when the gn patch was merged:

nnoremap *``cgn

nnoremap #``cgN

Hit to change the current word and ... to repeat on the next occurrences.

Re: A Vim Guide for Advanced Users

#79

Nice, but still wondering if I should know vim since nano is enough for me :)

Even as a daily emacs user I got value out of learning vi a while ago. It's better for some kinds of editing and generally works better than the emacs bindings for job interview browser apps.

Re: A Vim Guide for Advanced Users

#80
post #44

Earlier quoted context omitted.

I'm not sure exactly what your plugin does, but are you aware of the "c" flag to substitute, eg :%s/debug/dbg/c vim will show the text which is about to be modified, and you have a prompt to confirm, skip, or quit (and some others).

Yes, I am aware, but it's not nearly as flexible and quick. It doesn't allow me to in the meantime move my cursor around, switch buffers, undo, open/close a fold, etc. It takes complete control of your workflow to temporarily put you in some special 'search/replace mode' in a very non-Vimlike manner. My plugin has a simple operation (if cursor is on a match, replace, regardless jump to next match) that gets repeated…

If using the [c] flag and you want to interrupt it, a convenient way of continuing where you left off (and not touching previous lines, which may have new matches, depending on the nature of the replacement) may be :.,$&&, which means “operating on the range current line (.) to end of file ($), execute the last substitution (&) with the same flags as last time (&)”.

(This is very unlikely to interest you, but I mention it for the sake of others. I’ve commonly seen people not really know about ranges especially, never stopping and thinking about what the % means (see `:help :%` if you don’t know), beyond possibly having encountered ' by accident when pressing : in Visual mode (for explanation of these, see the help for :', ').)

Post reply on HN