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
  1. CLI
  2. Vim

<Ctrl-r>

In insert and command mode, <Ctrl-r> followed by a sequence inserts an object.

Insert mode usage mainly deals with manipulating registers. However, in command mode, <Ctrl-r><Ctrl-*> inserts special objects for certain *:

  • F: Current filename under cursor

  • P: Current filename with expanded path under cursor

  • W: Word under cursor

  • A: WORD under cursor

  • L: Line under cursor

For more, :help c-^r.

Insert word under cursor

Very useful with :Ag, or when doing find/replace.

:Ag <Ctrl-r><Ctrl-w>
:%s/<Ctrl-r><Ctrl-w>/replacement-string
PreviousBuffersNextExternal commands

Last updated 3 years ago