Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reconquest/vim-autosurround
Automatically insert pairs (brackets, quotes) where they are supposed to be
https://github.com/reconquest/vim-autosurround
braces pair surround vim
Last synced: 2 months ago
JSON representation
Automatically insert pairs (brackets, quotes) where they are supposed to be
- Host: GitHub
- URL: https://github.com/reconquest/vim-autosurround
- Owner: reconquest
- Created: 2015-10-11T17:16:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-07-31T09:53:01.000Z (over 2 years ago)
- Last Synced: 2024-08-08T23:26:31.287Z (6 months ago)
- Topics: braces, pair, surround, vim
- Language: Python
- Size: 43 KB
- Stars: 54
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Plugin will automatically add enclosing `)` (or any other) at appropriate place to be.
![gif](https://cloud.githubusercontent.com/assets/674812/10417889/f530e936-703a-11e5-8f77-2b7f6fe23191.gif)
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
```viml
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)`, `callback` is a function
of one argument `cursor`, which is `vim.current.window.cursor`.`callback` should return tuple `(line, column)` with position, which will be
used for inserting pair character or `None`, if `callback` is not able to
find position.`index` can be used for `unregister_finder(index)`.
* `autosurround.unregister_finder(index)` will remove previously added
callback.