Live data from Hacker News

Vim – Minimal Setup Explained

guckes.net

51–60 of 114 posts

Re: Vim – Minimal Setup Explained

#51

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…

G takes a line number as its "object" like other vim commands. So 1G is the first line, 10G the tenth, etc. G is the last. (0G goes to the last line too.)

Re: Vim – Minimal Setup Explained

#52
post #28
post #16

Earlier quoted context omitted.

I wish Ctrl+[ wasn't tied to Esc. I hit that often instead of Ctrl+P. Haven't yet found a way to map Ctrl+[ to Ctrl+P without affecting behavior of Esc as well.

It's because your computer can't tell the difference. c-[ and ESC send the same key-code. Same with c-i and tab. What you can do to get around this is to remap one of them to something like f20 using Karabiner, then map f20 to what you like in vim.

Thanks. Not sure if Karabiner is available for Linux, but I found https://stackoverflow.com/questions/41364833/karabiner-for-l... which might help me.

Re: Vim – Minimal Setup Explained

#53

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

Caps Lock being Esc is so convenient that I use Esc a lot more outside of Vim too. Stop the browser loading a page? a quick pinky tap on the caps lock. Take the focus out of a text field (so I can use my Vimium commands)? tap the caps lock. Decide not to save or open that file after all? caps lock's got your back.

The remapping was originally for Vim, but now at least a third of my Esc usage is outside of it.

Re: Vim – Minimal Setup Explained

#54

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…

For a case like that, I'll use rectangular block mode--it's really fast and intuitive, so I'll usually pick that over :s/a/b/g if it's applicable.

The whole thing would be something like 5jecs. Ctrl-v starts rectangular block mode, go down 5 lines and to the end of the word, change selection to "s", return to normal mode.

Re: Vim – Minimal Setup Explained

#55
The only thing I've really struggled with when trying to get into using vim full-time is navigating my project. In VSCode I basically hit CTRL+SHIT+F -> "portion_of_a_function_name_or_something" constantly. I abuse the heck out of global search. Is there a way of navigating your project in vim that's similar/easier?

How do vim people quickly navigate their code without going "what was the name of that file with that function"?

Re: Vim – Minimal Setup Explained

#56

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

Muscle memory. It feels clunky at first, especially when coming from a non-modal editor, but I hardly realize I am even doing it any more.

Re: Vim – Minimal Setup Explained

#57

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

Its the weakest part of the vim keyboard scheme IMO for ergonomics, and switching modes in general. I wish there was an alternative that gave a nod to vim but remained in 'input' mode without loss of capability, you know...without having to be vscode. If the key layout wasnt even worse, and it wasn't a bloated mess (on windows at least) I'd have switched to Emacs. Capslock is mostly a redundant button so I wholey sup…

> I wish there was an alternative that gave a nod to vim but remained in 'input' mode without loss of capability

Problem is, without modes, we lose capability that comes from the fact that modes exist, such as simple characters being compositeable commands;

How should a non-modal editor know whether that [d] I just pressed is me wanting the letter `d` or the delete command? It can't;

Either I have to somehow tell it "the next letter I press is to be interpreted as a command", or "interpret what I press as commands until I say otherwise". The former gets tiresome rather quickly (what if I have to do several commands?), the latter would again be a modal editor.

Re: Vim – Minimal Setup Explained

#58

The only thing I've really struggled with when trying to get into using vim full-time is navigating my project. In VSCode I basically hit CTRL+SHIT+F -> "portion_of_a_function_name_or_something" constantly. I abuse the heck out of global search. Is there a way of navigating your project in vim that's similar/easier? How do vim people quickly navigate their code without going "what was the name of that file with that…

I use neovim now and have switched my search over to using Telescope.nvim which is a fuzzy search basically.

It lets you do pretty much what you say allowing me to type -f and partially type things to remember where I am with a preview pane. Seems moderately fast most of the time for the monolith I work on.

Re: Vim – Minimal Setup Explained

#59

The only thing I've really struggled with when trying to get into using vim full-time is navigating my project. In VSCode I basically hit CTRL+SHIT+F -> "portion_of_a_function_name_or_something" constantly. I abuse the heck out of global search. Is there a way of navigating your project in vim that's similar/easier? How do vim people quickly navigate their code without going "what was the name of that file with that…

Historically, people used :grep and the quicklist to jump between project files based on abitrary strings and Ctags to generate a language specific index of functions, variables which you can jump to.

These days people generally use some kind of fuzzy finder plugin thats basically the same as the vscode experience. Exactly which one you use depends on various factors, but Telescope and Fzf are two big names and both allow searching through a bunch of other stuff, setting names, edit history etc. (You can also save the fuzzy search results to the quicklist so you've basically got a reusable index).

And neovim is heavily embracing the LSP paradigm, where you'd use something like gd to jump to definition when on top of a function and a language specific LSP server will tell Neovim where to jump to.

Re: Vim – Minimal Setup Explained

#60

The only thing I've really struggled with when trying to get into using vim full-time is navigating my project. In VSCode I basically hit CTRL+SHIT+F -> "portion_of_a_function_name_or_something" constantly. I abuse the heck out of global search. Is there a way of navigating your project in vim that's similar/easier? How do vim people quickly navigate their code without going "what was the name of that file with that…

Vim supports ctags[0] lookup out of the box which fits your need somewhat.

I tend to use FZF[1] which has functions for leveraging ripgrep and silver surfer for searches. It can also use find. FZF also has dialogues for paring down results in real time (i.e., as you type)

There are also plugins that are much more nuanced and more involved for searching symbols and providing autocomplete. Duoplete, vimcomplete, youcompleteme spring to mind.

[0]: https://ctags.io/

[1]: https://github.com/junegunn/fzf.vim

Post reply on HN