A plugin intended to make life simpler when inserting or appending characters
to blocks of text
Blockinsert can take a range but if no such is given it will act upon the
current paragraph.
First line of code
Another line of code
Yet another one
Last line of code
[count] \i-
will transform the above into: (count 3 used)
---First line of code
---Another line of code
---Yet another one
---Last line of code
[count] \a>
will transform the above into: (count 2 used)
---First line of code>>
---Another line of code>>
---Yet another one>>
---Last line of code>>
[count] \i
or \a
without any text will delete as many characters: (3\i
used)
First line of code>>
Another line of code>>
Yet another one>>
Last line of code>>
[count] \[]
will use both \i
and \a
: (2\[]
Left text:*
, Right text:**
used)
Note: the same [count]
will be applied to both operations
**First line of code>>****
**Another line of code>>****
**Yet another one>>****
**Last line of code>>****
[count] \[[
will use both \i
and \a
and the same text: (|
used)
|**First line of code>>****|
|**Another line of code>>****|
|**Yet another one>>****|
|**Last line of code>>****|
\qi
, \qa
and \q[]
will execute rather than write the text in input.
Example with \qa gUaW
:
|**First line of CODE>>****|
|**Another line of CODE>>****|
|**Yet another ONE>>****|
|**Last line of CODE>>****|
This plugin integrates with Tim Pope's repeat plugin. It means that you can use
. (dot) to repeat any blockinsert mapping you just used!
For more information see: http://github.com/tpope/vim-repeat
The visual mappings do the same work as the normal ones,
The only difference is that here the range is defined by the selected lines.
There is one special case. When selecting text in visual block mode, the
boundaries of the text acted upon are defined by the limits of the visual area.
Example: (the <bar>
s represent our selection)
Some text here |stridx( | end of this line
Some other text... |strridx( | text after a function
Let's start a third line |strlen( | ...finish this line
End of paragraph |substitute(| end indeed.
Now that a selection has been defined, all you need to do is type:
\a
followed by )
and your text will become:
Some text here stridx() end of this line
Some other text... strridx() text after a function
Let's start a third line strlen() ...finish this line
End of paragraph substitute() end indeed.
The following commands are also available, meant as an alternative to the
normal and visual mappings:
BlockInsert text
BlockAppend text
BlockQInsert actions
BlockQAppend actions
BlockBoth text1 text2
BlockBothSame text
BlockQBoth actions1 actions2
BlockQBothSame actions
The commands are disabled by default. Put this line in your vimrc if you want
them enabled:
:let g:blockinsert_commands = 1
@Todo: make the commands accept a count as their first argument
You have the possibility to define your own custom mappings in your vimrc:
vmap <leader>i <plug>blockinsert-i
vmap <leader>a <plug>blockinsert-a
vmap <leader>qi <plug>blockinsert-qi
vmap <leader>qa <plug>blockinsert-qa
nmap <leader>i <plug>blockinsert-i
nmap <leader>a <plug>blockinsert-a
nmap <leader>qi <plug>blockinsert-qi
nmap <leader>qa <plug>blockinsert-qa
vmap <leader>[] <plug>blockinsert-b
vmap <leader>[[ <plug>blockinsert-ub
vmap <leader>]] <plug>blockinsert-ub
vmap <leader>q[] <plug>blockinsert-qb
vmap <leader>q[[ <plug>blockinsert-uqb
vmap <leader>q]] <plug>blockinsert-uqb
nmap <leader>[] <plug>blockinsert-b
nmap <leader>[[ <plug>blockinsert-ub
nmap <leader>]] <plug>blockinsert-ub
nmap <leader>q[] <plug>blockinsert-qb
nmap <leader>q[[ <plug>blockinsert-uqb
nmap <leader>q]] <plug>blockinsert-uqb
Note: You can replace \i
, \a
, \qi
, \qa
, \[]
, \[[
, \]]
, \q[]
, \q[[
, \q]]
with whatever you like.