Live data from Hacker News

Vim – Minimal Setup Explained

guckes.net

41–50 of 114 posts

Re: Vim – Minimal Setup Explained

#41

Question for Vim users: how do you get used to hitting Esc very often? I know some switch Cap with Esc but still clunky.

I use `jk` or `jj` instead of esc. Its so much easier imap jj

Doom Emacs had this behavior by default, and it caught me by surprise when it prevented me from typing "noto-fonts-cjk." I knew a lot of people do this in Vim, but it took some time to figure out exactly what had happened. Excellent framework though.

Re: Vim – Minimal Setup Explained

#42

Since I was in university 15 years ago I promised myself to learn Vim commands seriously. Well I see that finally I did my programmer life learning only switching insert mode / edit mode, maybe 5 commands like A x etc...,and :q or :wq!

I relate quite heavily to this when using vi to do all my git-related activities. git rebase -i ... followed by ↓dw ↓←dw ↓←dw ↓←dw ↓←dw ↓←dw i s ↓s ↓s ↓s ↓s ↓s because I keep forgetting :s/pick/s/g is a thing i, a, :q, :wq, dd, xdd, and D are all the ones I remember, but cutting/yanking pasting is still something I don't have the muscle memory for. Shift+G takes me to the bottom of a file, but I don't know how to get…

I'm guessing you want

:%s/^pick/s/

to replace "pick" at the start of line with "s" on all lines? If you execute it once in vim you can recall it later with just typing

:%↑

and confirm with Enter.

As for the top of the file:

gg

I use the mnemonic "go go line" (as in Inspector Gadget's "go go gadget") and since you can prefix it with a line number (e.g. 4gg to go to line number 4), leaving it out gets me as close to line number nothing^Wzero as possible, i.e. line 1.

HTH :)

PS: the % says "on all lines" your trailing "/g" would make it match&replace "pick" multiple times on the (current, since % is missing) line

PPS: As an aside, I use "vim somefile +N" all the time to open somefile at line number N;

especially when there's an error message in the form "error at somefile:N" by typing vim, then double-click-middle-click copy&pasting "somefile:N", Ctrl-E to jump to the end and replacing ":" with " +". I really should write a shell function for that...

EDIT: formatting

Re: Vim – Minimal Setup Explained

#43

Question for Vim users: how do you get used to hitting Esc very often? I know some switch Cap with Esc but still clunky.

We simply do get used to that and all the rest. The benefits of modal editing far outweigh the eventual clunkiness of pressing a given key now and then. But the more you know how to use Vim, the less you need to get in and out of insert mode and the less you need to hit .

Re: Vim – Minimal Setup Explained

#44

Since I was in university 15 years ago I promised myself to learn Vim commands seriously. Well I see that finally I did my programmer life learning only switching insert mode / edit mode, maybe 5 commands like A x etc...,and :q or :wq!

I relate quite heavily to this when using vi to do all my git-related activities. git rebase -i ... followed by ↓dw ↓←dw ↓←dw ↓←dw ↓←dw ↓←dw i s ↓s ↓s ↓s ↓s ↓s because I keep forgetting :s/pick/s/g is a thing i, a, :q, :wq, dd, xdd, and D are all the ones I remember, but cutting/yanking pasting is still something I don't have the muscle memory for. Shift+G takes me to the bottom of a file, but I don't know how to get…

> Shift+G takes me to the bottom of a file, but I don't know how to get back to the top :D

I know the complement to Shift+G, it's gg. But I can never remember which one goes to the top and which to the bottom, so half the time I press both. :)

Re: Vim – Minimal Setup Explained

#45
post #33

Since I was in university 15 years ago I promised myself to learn Vim commands seriously. Well I see that finally I did my programmer life learning only switching insert mode / edit mode, maybe 5 commands like A x etc...,and :q or :wq!

Please learn dot ".". It repeats the last edit action. It's so powerful.

I use macros way more often than dot. With a macro I can include the movement action of getting to the correct position before the edit takes place, I'm not sure if this can be done with the dot key alone.

Re: Vim – Minimal Setup Explained

#46
post #2

While the information in there is good, a bunch of the settings are now redundant¹. The ones that jumped out to me were esckeys, ruler and showcmd. Not that I'm saying you can't — or shouldn't — re-set options, just that the linked documentation is a little dated. FWIW, I personally re-set a couple of default options mostly so that I have a point of reference for how an option works when I'm digging about in my confi…

defaults.vim was and still is an abject idea that we sadly can't get rid off, now that it has been there for a few years.

The least desirable property of defaults.vim is also present in sensible or in system-wide vimrcs written by package maintainers: you get a black box where things are added/changed/removed without your knowledge or consent. "Your" so-called minimal setup is going to evolve over time, but not according to "your" needs.

We got so many support request related to that silly mechanism that's not even funny.

Re: Vim – Minimal Setup Explained

#47
post #17

See also `:h defaults.vim-explained` ( https://vimhelp.org/usr_05.txt.html#05.3 ) which now comes by default. You can either copy the settings you are interested in or source it entirely in your vimrc file: source $VIMRUNTIME/defaults.vim --- Here's some more related resource links: * stackoverflow: useful .vimrc tips - ( https://stackoverflow.com/q/164847/4082052 ) * vi.stackexchange: How do I debug my vimrc file? -…

Please, no. Someone else's vimrc is the last thing newcomers need.

Re: Vim – Minimal Setup Explained

#48

Question for Vim users: how do you get used to hitting Esc very often? I know some switch Cap with Esc but still clunky.

On my Ultimate Hacking Keyboard I have a mapping of (left)space+q to produce Esc which for this combo I hit comfortably with my left hand thumb + ring finger.

On other keyboards I find fishing for the Esc key with the left ring or sometimes even middle finger good enough since it's so prominently singled out on the top left corner on all the keyboards I had yet to use, but it breaks the flow a bit more.

It probably helps that I'm not typing in proper form for the 10-finger system but only some hodgepodge approximation of it...

Re: Vim – Minimal Setup Explained

#49
post #45
post #33

Earlier quoted context omitted.

Please learn dot ".". It repeats the last edit action. It's so powerful.

I use macros way more often than dot. With a macro I can include the movement action of getting to the correct position before the edit takes place, I'm not sure if this can be done with the dot key alone.

Whether one uses . or a macro (manual or recorded) should depend on the current situation. It's really not a "pick one and stick with" it kind of situation.
Post reply on HN