I installed this vimrc configuration (including plugins), and saw that vim-surround was included. With that, the surround-readme tells me I can use things like ds" to delete surrounding quotes.

However, s triggers a substitute of the character under the cursor + placing me in insert mode (:help s says s is a synonym for cl).

I can't find this referenced in the config, so I'm wondering why I can't use surround?

Sorry if this is very stupid, new to Vim...

If it matters, this is the output of vim --version for me:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 12 2016 17:17:45)
MacOS X (unix) version
Included patches: 1-2
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     -gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
-clientserver    +insert_expand   +packages        -toolbar
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        +perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             +rightleft       +writebackup
+diff            +menu            +ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          
+farsi           +mouse_netterm   +tag_binary      
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/Cellar/python/2.7.12/Frameworks -framework Python   -lruby.2.3.0 -lobjc -L/usr/local/Cellar/ruby/2.3.1/lib    
  • 1
    It isn't d, s! It's ds. You should type ds so fast and then " ( or any other surrounding charachter). – dNitro Sep 19 '16 at 20:31
  • 3
    Don't use someone else's vimrc. – romainl Sep 20 '16 at 5:21

Yes, s is a synonym for cl. tpope/vim-surround does not change this, it adds new operators. The full list of operators that vim-surround adds is

  • ds<foo> which the mnemonic is (D)elete (S)urrounding foo. For example, ds", or ds(

  • cs<foo><bar> which the mnemonic is (C)hange (S)urrounding foo to bar. For example, to go from single to double quotes, use cs"'

and lastly

  • ys<motion><foo> which doesn't have a great mnemonic. You can just think of it as "surround". This one will surround the <motion> with foo. For example, to surround 2 words with parenthesis, use ys2w) (or use (, both of them work, but subtly different)

As well as this, it provides the visual mode mapping S which is just (S)urround the visual selection.

If pressing ds" doesn't work for you, you could be typing it too slowly. For example, d<pause>s<pause>" will be seen by vim as d<timeout> which cancels the d operator, followed by s" which deletes one character, puts you in insert mode and inserts a ". To fix this, you must type it faster.

If you don't want to type it that quickly, or if you can't, you could also try adjusting timeoutlen or timeout. timeoutlen changes how long vim waits before a command times out (in milliseconds). So you could set it to

:set timeoutlen=2500

for 2.5 seconds, or whatever you want. Or you could do

:se notimeout

which makes it so no commands ever time out, no matter how long you wait.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.