32

Just installed the surround plugin.

New buffer, type Hello World. Say I want to surround that with quotes.

In normal mode, V to get into visual mode, s to get into surround

Except it doesn't, s deletes the entire line.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
Bob
  • 3,283
  • 3
  • 20
  • 14

2 Answers2

24

The default visual mode mapping of surround.vim is Shift-S, not lowercase s.

You can check whether it's defined with :verbose vmap S. Do the other surround.vim mappings (ys, cs, ...) work? If not, check :scriptnames and :set runtimepath? for troubleshooting.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • 2
    Yes, `S` is the correct mapping in visual mode. See`:h surround-replacements`. `s` is already mapped for visual mode, so `S` was chosen instead... (confusing at first) See `:h v_s` for info on visual mode s operator. Note there is a visual mode `S` by default too. But because it is a synonym for visual `R`, the vim surround plugin overrides visual `S` with its surround command. – darcyparker Dec 06 '12 at 22:44
  • 1
    shift-s insert an additional space.How to avoid that? – deven98602 Dec 29 '12 at 10:12
  • I basically want it behave like as shown by [jeffrey way](http://net.tutsplus.com/tutorials/other/vim-essential-plugin-surround/) – deven98602 Dec 29 '12 at 10:32
  • 3
    @deven98602 - Are you referring to the space inside the brackets? Because if so - use a left bracket if you want the additional space and a right bracket if you don't. e.g. `S[` will do `[ a ]`, and `S]` will do `[a]`. – 3cheesewheel Sep 11 '13 at 15:14
  • I have no idea what your answer is about. Highlighting line with "shift+v" then doing "shift+s" just goes to insert mode. I've installed this plugin with vundle. and what do you mean shift+S.. shift+s producing S.. totally confused. – holms May 11 '16 at 01:21
  • 1
    for those who want lowercase s to work: `vmap s S`. note that this uses a recursive mapping which is generally bad practice. i was hoping the plugin would expose a better way, but couldn't find it – WuTheFWasThat Jun 10 '16 at 20:24
  • not working for me, c is for change in vim. I want to quote the simple string, how should i do it then? – kamal Aug 19 '16 at 09:35
3

This can also be a key binding collision with the yankstack plugin. To fix it, append call yankstack#setup() to your .vimrc file. For more info, see the discussion on GitHub.

Jay B. Martin
  • 499
  • 4
  • 11