doorboy.vim is a smart plugin that serves you around brackets((){}[]
) and quotations('`"
).
Add this to your .vimrc file.
Plug 'itmammoth/doorboy.vim'
Then, :PlugInstall
Add this to your .vimrc file.
call dein#add('itmammoth/doorboy.vim')
Then, :call dein#install()
Plugin 'itmammoth/doorboy.vim'
... and many other plugin managers.
(|
represents the cursor position)
Type: (
Then: (|)
Type: "
Then: "|"
Auto closing brackets and quotations works properly in the cursor context.
When: 'string|'
Type: '
Then: 'string'|
When: {|}
Type: <Space>
Then: { | }
When: { | }
Type: <BS>
Then: {|}
Type: <BS>
Then: |
When: {|}
Type: <CR>
Then: {
|
}
doorboy.vim automatically provides some key-mappings to you.
"
'
|
/
on filetype ruby/
on filetype javascript and perl
(
{
[
)
}
]
<BS>
<Space>
<CR>
doorboy.vim NEVER overwrites the mapping with <BS>
,<Space>
and <CR>
if these keys are already taken, so in such a case, you need to add the preferred mappings to your .vimrc
file.
Available mapping functions are
- doorboy#map_backspace
- doorboy#map_space
- doorboy#map_cr
For instance (to go with neocomplete + endwise)
" inoremap <expr> <CR> (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
inoremap <CR> <Plug>MyCR
inoremap <expr> <Plug>MyCR (pumvisible() ? "\<C-y>" : "" ) . doorboy#map_cr()
" inoremap <expr><BS> neocomplete#smart_close_popup()."\<BS>"
inoremap <expr><BS> neocomplete#smart_close_popup().doorboy#map_backspace()
In the doorboy definition, quotation means one character that opens a specific literal and closes it as well.
You can add quotations with letting g:doorboy_additional_quotations
variable.
"
" g:doorboy_additional_quotations must be a dictionary,
" and which has filetypes as its keys and quotations as its values.
" (filetype '*' means any filetypes.)
"
let g:doorboy_additional_quotations = {
\ '*': ['@'],
\ 'coffee': ['/']
\ }
If you find your customizing useful for all vimmers, please just send me a pull request. Thanks.
You can keep some quotations from being mapped by doorboy with letting g:doorboy_nomap_quotations
variable.
let g:doorboy_nomap_quotations = {
\ 'javascript': ['/']
\ }
You can add brackets with letting g:doorboy_additional_brackets
variable.
let g:doorboy_additional_brackets = {
\ 'html': ['<>']
\ }
You can keep some brackets from being mapped by doorboy with letting g:doorboy_nomap_brackets
variable.
let g:doorboy_nomap_brackets = {
\ 'vim': ['{}']
\ }
Fork it, then run the commands below for vim-flavored testing.
$ bundle install
$ git clone https://github.com/slim-template/vim-slim.git vim-slim
$ rake test
(The slim ftplugin in dooboy requires vim-slim, so you need to git-clone it in your workspace.)
blankslate.vimrc
is an essential vim script file for manual testing.
$ vim -u blankslate.vimrc
Now you can try vim plugged in doorboy.vim
MIT License.