Live data from Hacker News

A Vim Guide for Advanced Users

thevaluable.dev

131–140 of 179 posts

Re: A Vim Guide for Advanced Users

#131

Earlier quoted context omitted.

This might be the right audience for this little vimrc tidbit: "Press space to highlight current word nnoremap \ :let @/='\ =expand(" ") \>' :set hls This works just like *, except that it leaves your cursor where it is. You can then use n/p/whatever as normal.

This is useful enough that I wonder why you chose not to just map it to *. Is there a reason you did not?

Because is even easier to hit :)

Edit: also because I try and keep my keybinds as close to default as I can, and is oddly underused.

Re: A Vim Guide for Advanced Users

#132
post #81

Earlier quoted context omitted.

I used to work near a gym called “Vim Fitness”[0] in Cambridge, MA and there were endless jokes about trainers calling out: “H! J! K! L!” [0] https://vimfitness.com/

I bet it's constantly crowded since no one can figure out how to exit.

[deleted]

Re: A Vim Guide for Advanced Users

#133

Earlier quoted context omitted.

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…

> 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. I've mapped cnext and cprev to tab and shift-tab, to make it easy to bounce through things. Also, in my shell I have defined alias cbuf='vim - -c cbuffer!' which lets me do things like "make | cbuf" or "git grep -n foo | cbuf", which is great. Tan…

I like that mapping. Typing ":cnext" and ":cprev" is quite awkward. Next time I use vim's quickfix list I'll try tab + shift-tab.

I've been using VS Code + its Vim plugin recently anyway because I wanted to try out rust-analyzer and couldn't get it to work well with vim. (iirc I tried both YouCompleteMe and coc.nvim. Despite the name, the latter on classic vim; I haven't tried neovim yet. I thought they were supposed to be async, but at least one of them made vim hang for a long time when opening a fresh project, which drove me nuts.)

Neat idea also with the alias. Do you also have alias make='make 2>&1' or something? [edit: maybe make() { /path/to/make "$@" 2>&1 }] It doesn't work for me otherwise since compiler/make errors go to stderr (as they should).

Re: A Vim Guide for Advanced Users

#134
post #119

Earlier quoted context omitted.

The docs for this is in `:help v_CTRL-A`. It should actually say VISUAL BLOCK mode. This is where you use `CTRL-v` to select a block of text. You can read more in `:help blockwise-visual`. Also see the 'nrformats' option: `:help 'nrformats'`. You can include alphabetic characters to do the same thing with A-Z, for example. https://vimhelp.org/change.txt.html#v_CTRL-A

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!

Re: A Vim Guide for Advanced Users

#135

Earlier quoted context omitted.

> 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. I've mapped cnext and cprev to tab and shift-tab, to make it easy to bounce through things. Also, in my shell I have defined alias cbuf='vim - -c cbuffer!' which lets me do things like "make | cbuf" or "git grep -n foo | cbuf", which is great. Tan…

I like that mapping. Typing ":cnext" and ":cprev" is quite awkward. Next time I use vim's quickfix list I'll try tab + shift-tab. I've been using VS Code + its Vim plugin recently anyway because I wanted to try out rust-analyzer and couldn't get it to work well with vim. (iirc I tried both YouCompleteMe and coc.nvim. Despite the name, the latter on classic vim; I haven't tried neovim yet. I thought they were supposed…

> Do you also have alias make='make 2>&1' or something?

Ah, no, I probably just did `make 2>&1 | cbuf`; haven't actually been on a project using make in a while.

Re: A Vim Guide for Advanced Users

#136
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.

This is exactly what I'll be doing with these articles for the next few weeks. Learning a few cmomands at a time gives them time to sink in and become habit.

Re: A Vim Guide for Advanced Users

#137

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

I know the basics because vi ships with practically ever *nix (unlike Emacs), so it's there for when I need to edit config files, but I do 97% of my real work in something more like IntelliJ, so there just aren't big returns for getting better at vim.

My professor takes an excrutiatingly long time to edit files in class using keyb + mouse in IntelliJ. I am frequently waiting on him to finish up because of the vim plugin for IntelliJ. The speed of editing with vim, once you learn it, is shocking.

Re: A Vim Guide for Advanced Users

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

Re your edit: they explain it pastes the output of the command directly into your buffer, rather than temporarily showing you a shell with the output.

Re: A Vim Guide for Advanced Users

#140
post #19

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

I took Drew's Vim Masterclass with some coworkers years ago. I considered myself a fairly advanced Vim user at the time, and still learned some handy things during his class. It was a small group (we hired him just for our group of coworkers), and he took time to answer everyone's questions. He's got a great teaching style. I'm not sure if he still does the class, but if so, I recommend it for all Vim users.
Post reply on HN