Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I love vim. I am not one of those users who has a huge number of plugins and takes part in an extended eco-system that they perhaps do not fully understand -- for the last ~20 years of my life I have been trying to learn a little more vim each time I use it. I often don't, but it just has so many surprises that when I feel frustrated, I try to work out the "vimmish" way of doing things. Occasionally I give into temptation and take this to extremes -- for example, writing macros that look like alphabet soup to make certain coding tasks easier. I'm never sure if this is really a good use of my time -- but I do enjoy it. I'm so grateful it exists -- it's everywhere, insanely fast, lightweight, and I've never crashed it.

Now, if there is one feature I would add to Vim, it would be "cat detection". I have a ginger cat that is irritatingly in the habit of jumping on the keyboard when he wants food.

You can only imagine how, in command mode, he effectively summons the textual equivalent of the Nine Hells of Ba'ator upon my open documents if I am not quick enough...



> You can only imagine how, in command mode, he effectively summons the textual equivalent of the Nine Hells of Ba'ator upon my open documents if I am not quick enough...

There's always [u]ndo. Or you can use

:earlier 2m

to go back 2 minutes in time.


> go back 2 minutes in time.

Honestly this is single-handed my favorite thing about vim.

Not the ability to fluently traverse through text (and apparently time).

But that you can use it for a almost decade, and still have a stranger on the internet blow your mind with simple features you didn't know existed. There's so many of those one-off commands that are so useful, yet you've somehow never heard of them?


> to go back 2 minutes in time.

Wut.

~27 years of using vim, you just blew my mind.


[distant yelling of human segmentation faults]


crazy thing with vim is every person I've seen uses a different subset of functionality, which always contains a few things I've never seen before. Which is also pretty cool in my book. No two people use vim the same way.


Yeah same. I feel like a new man.


<shaking head> you always learn something old about vim every day!


me Monday morning:

:later 8h

One can dream...


Copilot in 2030 /s


> still blank

Fair enough


To save some typing, seems :ea is an alias for it, unless you got more commands starting with ea.

I normally use u (undo) though.


Okay I might need to start using vim!


You can do something very similar with nano.

If you have `set backupdir` enabled, any and all savepoints on a file are backed up with timestamps and a revision number.


Any sufficiently advanced Vim macro is indistinguishable from catwords.


Am a similarly profiled (neo)vim user .. but without cat. Sometimes I catch strange letter combinations like "gqip" in my emails that baffle the recipients. Want vim keys everywhere!


If you want Vim keys everywhere…

A friend of mine I met through my own similar (free) library is developing this like a madman: https://kindavim.app

It costs $3/month (coffee) but for a Vim person like me I gladly pay. Making this work across macOS is a total mess and a full-time job, and it's not trivial work.

If you want a free version, I have https://github.com/dbalatero/VimMode.spoon as a Hammerspoon plugin that works pretty OK, but I'm not actively developing it and prefer the kindaVim app at this point.


Dang that’s cool, I used tridactyl a bit in web browsers and it just got too messy in a browser (in addition to the new key bindings). In theory I support this endeavor but one of my biggest annoyances is when applications “overwrite” default/expected keybindings (looking at you excel web app). It seems to me a large part of web accessibility is being able to navigate a computer without even a mouse (hey that’s what vim does) but I really wish there was full OS support for this (seems to be the goal for kindaVim?) opposed to a “layer”. Certainly best of luck and cheers to the development efforts - have taken note


I can also recommend sketchyVim as I think it just uses your normal .vimrc file for its configuration and it’s FOSS.


This is me all the time. The worst is “kkk”. I can’t remember why I type it in vim (it’s muscle memory, and I’m not at a computer to try it out), but it has really bad connotations here in the US south, so… no bueno.


Unsolicited advice for scrolling without spamming j and k:

- C-u and C-d to jump up/down

- [ and ] to go prev/next empty line (I have a macro to clear empty spaces at the end of lines so this works well for jumping functions in code)

- from the article: 50% to go the halfway point of a document

- 100gg to go to line 100

- 100k to go 100 lines down

Are there any more good ones?

Edit: occurs to me that you might have remapped kkk to escape normal mode. At one time I had done this for jj. Now I just use C-[ as it’s portable to vanilla vim setups and less of a stretch than the escape key.


  :set relativenumber
The line the cursor is on is now shown in the left sidebar as 0, counting up for each line away from the cursor. So now it tells you what number to use for "10j" and "10k" to move up and down a specific number of lines.

   m[a-z]
   `[a-z]
Mark a point in a file into a register, and jump back to that point. Or even more interesting:

   m[A-Z]
   `[A-Z]
Same as above, except capital marks are global and work across files.

Also,

   ``
Jump back to the last place you jumped from (but only within the same file).


My only problem with relative line numbers (and I use them despite this) is working with ranges of line numbers. For instance, I'll maybe be doing some refactoring and want to see what it looks like to move lines 127,137 to my current cursor (127,137t.). With relative line numbers I have to do some quick arithmetic to sort out the range.


I believe it's possible to enable relative and absolute numbers at the same time


I also set scrolloff to 10 or so that way I can always see what's above/below what I'm currently editing.


H, M, and L will move the cursor to the top, middle and bottom (respectively) of the screen. That is, H moves the cursor to the top visible line on the screen, L to the last line currently visible, and M to the middle. Cursor moves but text does not.

zt, zz, and zb are similar but move the text not the cursor. So, zt will take the current line the cursor is on and make it the first visible line on the screen (and keep the cursor on that line). zz to the middle, zb to the bottom.

Personally, I use [ and ] to jump around most often in code, but the above are handy when you are working with documents.


I like using L and H to go to bottom or top of screen to initiate scrolling with j or k. You can scroll up or down without moving the cursor using Ctrl-Y and Ctrl-E but I find those a bit hard to get used to.


> Are there any more good ones?

I find these handy, especially after doing a search (quoted from :h z):

- z. redraw, cursor line to center of window

- z<CR> redraw, cursor line to top of window

- z- redraw, cursor line at bottom of window


{ / } jump to start/end of the block.

Between that and 20j and (blasphemy probably) just using the scroll wheel, that handles most of my scrolling needs.


I think I meant to write { and } (which is previous/next empty line) instead of [ and ] which can be combined like [( ]) or [{ ]} to go to the beginning and end of parentheses and curly brackets respectively. % is good for jumping between matching parenthesis... I wish there was something like this for *ml tags inbuilt (e.g., go to matching <div> <-> </div>)


> advice for scrolling without spamming j and k

Or just use the directional keys and PgUp/PgDown like any person in the last 30 yrs


Every time my fingers have to leave the home row I feel pain. Mostly from knowing that I’m likely to typo straight after, or have to remove my gaze from the screen to check my fingers and then find my position on the screen again. It really breaks flow and that flow was a big motivation for me to start using vim


:1 to go to the top of the file, G to goto the bottom of the file


gg will take you up to the top as well


Not only in the US south. In Germany, there is a health insurance called "Kaufmännische Krankenkasse", and when I first saw their name abbreviated, I wondered why it was written KKH for about half a second...


KKH = Kaufmännische Krankenkasse Hauptverwaltung


I always map jj to esc in my vimrc so I don't have to leave the home row. My code in vscode often fails to compile at first because lines end with ;jj


Since I have no use for it, I like to globally (not just in vim) map caps to ESC.


Not a bad idea, but its still not the home row, and its a weak finger. If I wanted a pinky ginger workout I'd use emacs.

I may still try it out. But decade long habits...


It’s funny to read about this because I’m sure many people have this same internal thought process when using vim


Can I ask what kkk means?

I thought it meant that you were laughing like haha (a leas in Brazil)

I didn't know it had bad connotations



Perhaps in US but in Brazil it is common use to write kkk to laugh


In Brazil is just a laugh.


There's an AutoHotkey script for that!


Counter-intuitively, cats seem to prefer keyboards over mice when "working" at your PC...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: