-
Notifications
You must be signed in to change notification settings - Fork 37
Introduce vim surround keymappings
If you want to use with vim-surround keymappings, add the following line to your vimrc.
runtime macros/sandwich/keymap/surround.vim
ys
, yss
, yS
, ds
, cs
in normal mode and S
in visual mode are available. Not in vim-surround, but dss
and css
are also available, these are similar as ds
and cs
but determine deleted/replaced texts automatically. See the file directly for detail.
NOTE that the vim-sandwich plugin should be in 'runtimepath'
option when the :runtime
command is executed. If you are using a kind of plugin managers, like Vundle, plug or neobundle, the :execute
command should pe placed after vundle#end()
/plug#end()
/neobundle#end()
in your vimrc.
vundle#begin()
~~~
Plugin 'machakann/vim-sandwich'
~~~
vundle#end()
runtime macros/sandwich/keymap/surround.vim
Or just use :source
command instead.
source {full/path/to}/macros/sandwich/keymap/surround.vim
Please change {full/path/to} part for your environment.
Additionally, vim-sandwich provides several textobjects. They would also be helpful, give it a try!
xmap is <Plug>(textobj-sandwich-query-i)
xmap as <Plug>(textobj-sandwich-query-a)
omap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
- Examples
|<---- is( ---->|
{[(a_surrounded_text)]}
|<----- as( ----->|
|<----- is[ ----->|
{[(a_surrounded_text)]}
|<------ as[ ------>|
|<------ is{ ------>|
{[(a_surrounded_text)]}
|<------- as{ ------->|
|< is_ >|
{[(a_surrounded_text)]}
|<- as_ ->|
xmap iss <Plug>(textobj-sandwich-auto-i)
xmap ass <Plug>(textobj-sandwich-auto-a)
omap iss <Plug>(textobj-sandwich-auto-i)
omap ass <Plug>(textobj-sandwich-auto-a)
- Examples
|<---- iss ---->|
{[(a_surrounded_text)]}
|<----- ass ----->|
|<---- iss ---->|
({[a_surrounded_text]})
|<----- ass ----->|
|<---- iss ---->|
[({a_surrounded_text})]
|<----- ass ----->|
xmap im <Plug>(textobj-sandwich-literal-query-i)
xmap am <Plug>(textobj-sandwich-literal-query-a)
omap im <Plug>(textobj-sandwich-literal-query-i)
omap am <Plug>(textobj-sandwich-literal-query-a)
- Examples
|< im_ >|
{[(a_surrounded_text)]}
|<- am_ ->|
See also Bracket with spaces.