How to Surround Text in Vim, Without Plugins

June 7, 2025

Surrounding text in Vim/Neovim is not strictly complicated, but finding a good workflow is not immediately obvious either.

Recipe

demo of text surround in vim

Step by step below.

Step 1: “changing” text

Select text, and press c (change mode).

Alternatively, it’s that more convenient, you can use a “text object selection” like ciw to “change” a specific something.

select some text

selecting some text, in vim

press c (text is gone)

after selecting some text, in vim

2 birds with 1 scone:

Step 2: typing wrapper text

Type the wrapping characters yourself. (here: "")

typing the necessary wrapping characters, in vim

Go back to normal mode: press ESC

Step 3: pasting

With the cursor directly on the closing character, press P (capital p)

pasting the original text, in vim

Comments

I have used vim-surround for a long time. But when I switched from vim to neovim, I wasn’t sure if I really needed to plugin for this.

Discuss on Bluesky