Live data from Hacker News

Intermediate Vim

dn.ht

91–100 of 130 posts

Re: Intermediate Vim

#91

“If you’re like me and never learned to touch type properly, just use the arrow keys, it’s fine, don’t worry about it.” Are touch typists rare these days? I feel like people these days forego even learning to type properly. I dont understand why they refuse to just learn it, it is such an essential skill to have.

I think it’s hard for people to make themselves dedicate the time to learn something when they aren’t forced to. A big function of school is to force people to learn things, things they could perfectly well learn on their own if they didn’t lack the willpower.

I’m very grateful that my dad, recognizing back in the 90s how important a skill it was, made me learn to touch type when I was just six years old. I never got as good with the number row as with the letters, which was fine for a long time as I am very quick with the number pad, but nowadays I mostly use my laptop which doesn't have a number pad. It is a silly thing, because I could with a few minutes every day for a couple of weeks train myself to be as quick with the number row as with the letters, but I haven't and probably never will. There is no pressing need for it in my life and no one to force me to do it.

Re: Intermediate Vim

#93
post #78

For anybody who's found more IDE-y activities a bit beyond the current generation of VIM plugins (looking at you Typescript), the Vim plugins for VsCode and Visual Studio are actually surprisingly good and I find myself at least as productive as I do in Vim. I imagine it might be quite a good starting point for somebody who's used to VsCode productivity but wanted to get into vim without going full vim!

Just a warning for VSCode users, this issue still exists: https://github.com/VSCodeVim/Vim/issues/2007

Per the PR comments, a workaround I've been using is to have VSCodeVim use VSCode's own undo/redo stack (appended to settings.json)

    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["u"],
            "after": [],
            "commands": [
                {
                    "command": "undo",
                    "args": []
                }
            ]
        },
        {
            "before": [""],
            "after": [],
            "commands": [
                {
                    "command": "redo",
                    "args": []
                }
           ]
       }
  ],

Re: Intermediate Vim

#94
post #92

After years of using Vim, I recently learned that I could use `Ctrl+C` instead of `ESC` to get back to command mode. Mind blown.

Alt+Movement is what I usually use, since it's easy to hit on my keyboard, and lets you combine dropping out of insert mode and a movement command to move you towards where you want to be for whatever you want to do next.

If you don't want to move, you can just hit Alt+l as the "default" escape.

Re: Intermediate Vim

#95
post #90
post #60

Earlier quoted context omitted.

For that same example, you can accomplish the job in one substitute command: :%s/.*/"&",/ The & special character gets replaced with the whole matched pattern.

How do you escape the & character? I have been bit by this (not escaping &) a few times but never enough to have found the answer.

The same way you escape anything - with a \. E.g. if you wanted to substitute the character x with the sequence &/\ you would type

:s/x/\&\/\\

Re: Intermediate Vim

#96

I’d highly recommend Drew Neil’s Practical Vim[0] for much more like this; it’s broken down into easy chunks and gets into the _why_ as well as the _how_ of Vim’s techniques. Modern Vim[1], mentioned elsewhere in the comments, covers more advanced Vim usage. [0]: https://pragprog.com/book/dnvim2/practical-vim-second-editio... [1]: https://pragprog.com/book/modvim/modern-vim

Drew Neil also created great video tutorials, the vimcasts[1].

[1]: http://vimcasts.org/episodes/

Re: Intermediate Vim

#98
post #92

After years of using Vim, I recently learned that I could use `Ctrl+C` instead of `ESC` to get back to command mode. Mind blown.

I use that all the time except for the case where I'm doing a visual block insert when the control-c doesn't do what an escape does.

Re: Intermediate Vim

#99
post #3

As a Vim user one of my gripes when first using Vim was how cumbersome the built in help files were. I guess that's why there are so many "vim cheatsheets" out there, the built in documentation is a pain to use.

Respectfully disagree. I think vim's help documentation is quite good. The inbuilt reference is extensive and with examples as well.

Perhaps it's navigating the :help window you find cumbersome?

Re: Intermediate Vim

#100

Earlier quoted context omitted.

Another notable trick is that vim registers are case-insensitive -- and since macro's are just stored in registers, macro's are case-insenstitive as well. so @q == @Q, which alleviates some of the RSI problems with spamming @q.

I remember something about a capital register appending instead of overwriting -- is that only for saving (with no influence in execution)?

Yes, that's only for writing. For example, to collect all lines matching a pattern into a register with

  :g/pattern/y A
you need to use an uppercase register ("A" in this case) because it executes `y` once per match. With `y a` instead of `y A`, you would end up having only the last match in the register.
Post reply on HN