timhwang21.gitbook.io
  • Intro
  • Blog
    • 2023
    • 2022
    • 2021
    • 2020
    • 2019
  • CLI
    • Git
      • Bulk resolve merge conflicts
      • git rebase-onto
      • Patch from diff
    • Shell
      • Recipes
    • Vim
      • Batch editing
      • Buffers
      • <Ctrl-r>
      • External commands
      • :global
      • Help
      • Registers
      • Splits
    • Tools
  • Programming
    • React
      • Testing Styled Components
    • Typescript
      • curryRecord
      • Exhaustive conditionals with ADTs
      • newtype
      • OmitTypes
      • Safe JSON clone
      • Type inferrers
      • XOR type
    • Ruby
      • Pry
      • RSpec
    • Rails
      • Attributes
      • Cheap many to many
      • (Don't use) counter cache
    • Databases
      • Metrics
      • Testing indexes
  • Personal
    • Uses
    • Github
    • Medium
    • LinkedIn
    • Photography
Powered by GitBook
On this page
  • Special registers
  • Modify register contents with <Ctrl-r>REGISTER
  • Reuse contents of search register
  • Yank to system clipboard
  • Set system clipboard contents to current filepath
  • Run function on search results
  1. CLI
  2. Vim

Registers

Special registers

@ followed by a register symbol represents a register. In addition to the standard numbered registers @[0-9], there are several special registers.

  • :: command register

  • /: search register

  • %: filepath register

  • ": last yanked value register

  • +: system clipboard register

  • =: expression register

:reg for a complete list.

Modify register contents with <Ctrl-r>REGISTER

Note that since macros are just command sequences stored as a string in a register, you can edit macros this way as well.

:let @q='<Ctrl-r>q' # ...and then modify

Reuse contents of search register

Useful for when you search for something unwieldy to type and need to reuse it later (for a replace for example).

/some-long-and-complicated-search-string # search something arcane
:%s/<Ctrl-r>//replacement-string # reuse without retyping

Yank to system clipboard

"+y

Set system clipboard contents to current filepath

:let @+ = expand("%")

Run function on search results

g/\attribute :(\w\+\)/\=g:Abolish.dashcase(submatch(0))
PreviousHelpNextSplits

Last updated 3 years ago

Useful for transformations. The following will dashcase all capture group matches using .

abolish.vim