vimtricks.wiki Concise Vim tricks, one at a time.

How do I select or edit the content inside backtick-delimited text like Markdown code spans?

Answer

vi`

Explanation

Vim treats backticks as a valid quote delimiter for text objects, just like ' and ". The i`` text object selects the content **inside** a pair of backticks; a`` selects the content and the backticks themselves. This works for Markdown inline code spans, shell command substitutions, JavaScript template literals, and any other backtick-delimited text.

How it works

  • `vi`` — enter Visual mode and select inside backticks (the content between them)
  • va`` — select **a**round backticks (content + surrounding `` `` characters)
  • Works in Normal mode as an operator target: ci`` changes the content, di deletes it, `yi yanks it
  • The cursor can be anywhere on the line — Vim searches forward for the nearest backtick pair

Example

Given a Markdown line:

Run `git status` to check your repository.

With the cursor anywhere on the line:

  • vi`` selects git status`
  • ci`` deletes git status` and puts you in Insert mode to type the replacement
  • da`` deletes the entire `` git status` `` including the backticks

Tips

  • Works for all quote-like delimiters: vi' (single quotes), vi" (double quotes), vi( (parentheses), vi{ (curly braces), vi[ (square brackets)
  • In Markdown, ci` is the fastest way to update an inline code snippet without touching the surrounding text
  • For JavaScript template literals spanning multiple lines, vi`` may not work as expected — use va{` with the outer object instead
  • :set matchpairs does not affect quote text objects; those are always recognized by default

Next

How do I run a search and replace only within a visually selected region?