vim-autosurround
vim-autosurround copied to clipboard
Automatically insert pairs (brackets, quotes) where they are supposed to be
Plugin will automatically add enclosing ) (or any other) at appropriate place to be.

Currently, following cases are supported:
-
adding pair after call-like construction:
|something() type: test( -> test(|something()) -
adding pair after string:
|"blah" type: test( -> test(|"blah") -
adding pair after argument:
something(|arg1, arg2) type: test( -> something(test(|arg1), arg2)something(arg1, |arg2) type: test( -> something(arg1, test(arg2)) -
adding pairs in conditionals:
if |blah != nil type test( -> if test(blah) != nil -
autocorrection:
something(|arg1, arg2) type: test( -> something(test(|arg1), arg2) move cursor after last ) and type ) -> something(test(arg1), arg2)| something(test(arg1, arg2))|
Installation & Usage
Plug 'vim-autosurround'
Plugin provides only python API.
Extension
Plugin provides API, which can be used to extend surround logic:
-
index = autosurround.register_finder(callback),callbackis a function of one argumentcursor, which isvim.current.window.cursor.callbackshould return tuple(line, column)with position, which will be used for inserting pair character orNone, ifcallbackis not able to find position.indexcan be used forunregister_finder(index). -
autosurround.unregister_finder(index)will remove previously added callback.