Using Vim surround plugin

I just downloaded vim today.

surround plugin documentation says:

Press cs"' inside "Hello world!" To change it to 'Hello world!' .

But where should I press cs"' and in what mode?

+6
vim plugins
source share
2 answers

Just downloaded vim? You made the right choice!

Vim has several modes.

Paste mode is what you use to enter text. This is not what you use to move around the document (in terms of vim, "buffer").

After you typed "Hello world":

press ESC to enter command mode.

use the hjkl keys to move the cursor inside the quotation marks.

then type cs "'to change the environment from" to "

Vim's online help is great.

In command mode, type: help surround to get help for the plugin

if you don’t see anything, first try: help helptags, which will tell you how to set up help files (the environment plugin also has great help)

+7
source share

Run vim, enter insert mode and type:

 "Hello, world!" 

Press esc to return to normal mode and go left at least once, now press cs"' and it will change to:

 'Hello, world!' 

(I just installed surround and tried just that, an Ubuntu-packaged vim 7.2 with my own .vimrc and plugins, but nothing that should affect that.)

+3
source share

All Articles