blockinsert : Easy Insert/Append to a paragraph of text
script karma |
Rating 8/2,
Downloaded by 2118 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Dimitar Dimitrov |
|
script type |
utility |
|
description |
Easy Insert/Append to a paragraph 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
1.1 Insert
[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
1.2 Append
[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>>
1.3 Delete
[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>>
1.4 Act on both ends
[count] \[] will use both \i and \a: (2\[] * ** 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>>****
1.5 Act on both ends using the same text
[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>>****|
1.6 Record
\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>>****|
==========================================================
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.
==========================================================
For all this to work you MUST define your 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. |
|
install details |
blockinsert.vim --> ~/.vim/plugin
blockinsert.txt --> ~/.vim/doc
Latest version at:
https://github.com/kurkale6ka/vim-blockinsert |
|
script versions (upload new version)
Click on the package to download.
blockinsert.zip |
4.1 |
2010-09-20 |
7.0 |
Dimitar Dimitrov |
A single line is a valid range now |
blockinsert.zip |
4.0 |
2010-09-18 |
7.0 |
Dimitar Dimitrov |
Deletion:
made it work correctly in visual block mode
repeating it doesn't require to re-enter empty text anymore
Improved interactive messages
Added support for right to left editing
Defined g:blockinsert_commands and used it to disable blockinsert commands by
default
When repeating actions performed on a visual block selection, blank portions of
text in the new area will be correctly skipped.
Corrected the virtualedit mess. Still need to disable it though.
Renamed the commands to begin with Block... & created Block[Q]BothSame.
Updated the help file. |
blockinsert.zip |
3.2 |
2010-09-17 |
7.0 |
Dimitar Dimitrov |
The mappings can now operate on a visual block area defined anywhere.
The . (dot) is able to repeat that action now. |
blockinsert.zip |
3.1 |
2010-09-16 |
7.0 |
Dimitar Dimitrov |
Corrected a small regression which made the use of . (dot) impossible. |
blockinsert.zip |
3.0 |
2010-09-16 |
7.0 |
Dimitar Dimitrov |
New feature:
Added the possibility to define the boundaries of the text acted upon by drawing a visual block selection.
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.
Enjoy.
todo: Add the possibility to repeat this action by typing . (dot)
todo: Create \[[, \]], \q[[, \q]] for cases where we want the same text on both ends. |
blockinsert.zip |
2.1 |
2010-09-15 |
7.0 |
Dimitar Dimitrov |
2 bug fixes:
- If a count was used with \qi, \qa or \q[], it wasn't interpreted correctly.
- There was also a problem with reseting virtualedit to its original value. |
blockinsert.zip |
2.0 |
2010-09-14 |
7.0 |
Dimitar Dimitrov |
Improved integration with the 'repeat' plugin.
The inserted / appended text is now remembered,
you don't have to re-enter it when repeating. |
blockinsert.zip |
1.1 |
2010-09-13 |
7.0 |
Dimitar Dimitrov |
Integrated blockinsert with Tim Pope's repeat plugin.
It is now possible to repeat blockinsert mappings by pressing . (dot)
More info about repeat:
http://www.vim.org/scripts/script.php?script_id=2136
http://github.com/tpope/vim-repeat |
blockinsert.zip |
1.0 |
2010-09-13 |
7.0 |
Dimitar Dimitrov |
Initial upload |
ip used for rating: 142.132.191.50
|