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

    "ayy - copy function signature

    "byy - copy return signature

    "ap "bp - paste either...

    :reg - show all registers

    "3p - paste 3rd "historical" register

    "_dd - delete into the /dev/null buffer (so you don't eat your `yy` register that you'd already yanked)
It's admittedly a bit of an advanced/esoteric feature, but being able to paste "this part" or "that part" being somewhat context dependent is useful.

Also useful in the context of macros... A, B, C being differing bits you might be "lifting", and then placing somewhere.

    i<c-r>" / i<c-r>a - recall (while in insert mode) the default, or the named register.
Imagine that your converting `function do_something() { ... }` to: `arr["do_something"] = function() { ... }`

You could delete the function name into "A", the function body into "B", then go back to your marked spot, and pull out the "A" into the hash key, and put "B" as the key value.

It's reeeally awkward and complicated until you use it and it becomes a natural part of your way of thinking. Then it becomes "simply" two extra characters to type when working with _any_ copy/paste task and then you have a super-power of 26 choices of holding things off to the side.

`<c-r>$REG` is honestly one of the best "beginner" uses of registers. It lets you "inline type" what you've just lifted/cut. eg:

     vwy - yank visible word into default register
     V"ay - yank whole line into register "a"
     I<c-r>"=<c-r>"+1 => `word = word + 1` (without having to exit insert mode!)
     "ap - paste the line from register "a"
...it's a small thing, but an important aspect of "vim as a live text-based programming language", having a few "hot" named variables / text strings, and being able to see them and manipulate them. It's literally just the double-quote key and ":reg" that gives you access to it.



Ah this is incredible, thank you. I didnt realize that about <c-r>... wow, that is crazy cool.

Next question, do you usually add stuff to buffers in alphabetical order... a,b,c or do you pick something easier within reach like a,s,d (or something else entirely)


Usually a/b/c but sometimes f/function, k/key, v/value... just a simple mnemonic.

To really blow your mind:

    i<c-r>%

    V:!ls<cr>
Then you start playing with marks a little bit with a similar concept (eg: ma, mb, mc, 'a, 'b, 'c), and the good friend `gi` (go back to previous insert position)...

It's again, esoteric, but as you use it more, it becomes less esoteric and more just another part of your vim vocabulary (:help search-offset, fellow traveler).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: