Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 's' in visual mode do?

Tags:

vim

vi

macvim

I have downloaded a new version of Tim Pope's surround plugin. I noticed he deprecated 's' in favor of uppercase 'S'.

He said this was to prevent interference with a lot of Vim user's muscle memory for hitting lower-case 's' in visual mode. I did some googling but I can't seem to find what exactly this does?

I'd like to know, just in case there is a good bit of info I should know about that key combo :)

like image 939
Tallboy Avatar asked May 04 '12 19:05

Tallboy


People also ask

What does visual mode do in vim?

Visual Block Mode of Vim allows us to perform different operations like delete, copy-paste, i.e., yanked and put, etc. To enable the Visual block mode in Vim, you have to try out the “Ctrl+V” command within the normal mode. You can see that the new. txt file has been opened in the Visual Block mode.

How do I exit visual mode?

If you're in character-wise visual mode, pressing v will exit visual mode. If you're in block-wise visual mode, pressing ctrl-v will exit visual mode.

How do I get into visual block mode?

Press Ctrl+v to enter visual block mode. The words VISUAL BLOCK will appear at the bottom of the screen. Use the Arrow keys to highlight the single character column. You can verify that each task is indented the same amount.

How do I paste in insert visual mode?

Before pasting into vim, enable paste mode by entering :set paste . Press i to enter insert mode. The status bar should say -- INSERT (paste) -- now. Press the right mouse button to paste in your stuff.


2 Answers

As described in the Vim manual:

{Visual}["x]c or v_c v_s {Visual}["x]s Delete the highlighted text [into register x] and start insert (for {Visual} see Visual-mode). {not in Vi}

So both c and s do the same thing in visual mode.

Also, in general, if you want to know what a key does in something other than normal mode, just prefix the key with the first letter of the mode and a underscore.

For example:

:help v_s

to find out what the s key does in visual mode.

like image 127
rjk Avatar answered Sep 23 '22 02:09

rjk


s does the same thing as x then i

essentially deleting the currently highlighted character(s) then entering insert mode

like image 34
g19fanatic Avatar answered Sep 24 '22 02:09

g19fanatic