7 Commits

Author SHA1 Message Date
Eric Wong
356cd3cca7 Merge b6b57ccb05 into becbd2d353 2024-11-06 09:58:31 +00:00
Israel Chauca Fuentes
becbd2d353 Merge pull request #308 from kevinhwang91/master
fix: &sw may be a zero
2024-08-06 01:02:38 -05:00
kevinhwang91
382c36bf57 fix: &sw may be a zero
E41: Out of memory!
2024-08-06 12:56:21 +08:00
wsdjeg
b6b57ccb05 remove table 2017-11-26 23:08:28 +08:00
wsdjeg
e91b50c2e6 Update readme 2017-11-26 23:04:41 +08:00
wsdjeg
54960895ce Update automatic closing & exiting section 2017-11-26 22:55:47 +08:00
wsdjeg
3aa8a4d3a8 Update readme 2017-11-26 22:45:02 +08:00
2 changed files with 87 additions and 7 deletions

View File

@@ -1,6 +1,85 @@
This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that
should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter
in comments and other configurable regions), <CR> and <Space> expansions (off by default), and some more.
# delimitMate
Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using
:autocmd.
> Vim plugin for automatic closing of quotes, parenthesis, brackets, etc.
## Installation
- [plug.vim](https://github.com/junegunn/vim-plug)
```vim
Plug 'Raimondi/delimitMate'
```
## Features
### Automatic closing & exiting
```
Type | You get
=======================
( | (|)
-----------|-----------
() | ()|
-----------|-----------
(<S-Tab> | ()|
-----------|-----------
{("<C-G>g | {("")}|
```
### Expansion of space and CR
Expand `<Space>` to:
```
You start with | You get
==============================
(|) | ( | )
```
Expand `<CR>` to:
```
You start with | You get
==============================
(|) | (
| |
| )
```
### Backspace
```
What | Before | After
==============================================
<BS> | call expand(|) | call expand|
--------|-------------------|-----------------
<BS> | call expand( | ) | call expand(|)
--------|-------------------|-----------------
<BS> | call expand( | call expand(|)
| | |
| ) |
--------|-------------------|-----------------
<S-BS> | call expand(|) | call expand(|
```
### Smart Quotes
```
What | Before | After
=======================================
" | Text | | Text "|"
" | "String| | "String"|
" | let i = "| | let i = "|"
'm | I| | I'm|
```
### BALANCING MATCHING PAIRS
```
e.g. typing at the "|": >
What | Before | After
=======================================
( | function| | function(|)
( | |var | (|var
```

View File

@@ -483,8 +483,9 @@ function! delimitMate#ExpandReturn() "{{{
" indentation is controlled by 'smartindent', and the first character on
" the new line is '}'. If this were typed manually it would reindent to
" match the current line. Let's reproduce that behavior.
let shifts = indent('.') / &sw
let spaces = indent('.') - (shifts * &sw)
let sw = &sw == 0 ? &ts : &sw
let shifts = indent('.') / sw
let spaces = indent('.') - (shifts * sw)
let val .= "^\<C-D>".repeat("\<C-T>", shifts).repeat(' ', spaces)
endif
" Expand: