vim-multiedit : Multi-selection editing for vim, inspired by Sublime Text
| script karma
Downloaded by 939
Comments, bugs, improvements
script versions (upload new version)
|Do you envy Sublime Text 2's multiple selection and editing feature? This plugin tries to fill that text cursor shaped gap in your heart by letting you specify "regions" of text and edit them all from one place.
Add edit-regions by using <leader>m in visual mode or <leader>mm in normal mode (selects the word under the cursor). You can also add disposable markers using <leader>mi (before cursor) and <leader>ma (after cursor).
Once all the regions are set, start editing with <leader>M (or <leader>C which will clear the main region before you start editing).
When you're done, leave insert mode and it will copy the changes to all other regions.
" Insert a disposable marker after the cursor
nmap <leader>ma :MultieditAddMark a<CR>
" Insert a disposable marker before the cursor
nmap <leader>mi :MultieditAddMark i<CR>
" Make a new line and insert a marker
nmap <leader>mo o<Esc>:MultieditAddMark i<CR>
nmap <leader>mO O<Esc>:MultieditAddMark i<CR>
" Insert a marker at the end/start of a line
nmap <leader>mA $:MultieditAddMark a<CR>
nmap <leader>mI ^:MultieditAddMark i<CR>
" Make the current selection/word an edit region
vmap <leader>m :MultieditAddRegion<CR>
nmap <leader>mm viw:MultieditAddRegion<CR>
" Restore the regions from a previous edit session
nmap <leader>mu :MultieditRestore<CR>
" Move cursor between regions n times
map ]m :MultieditHop 1<CR>
map [m :MultieditHop -1<CR>
" Start editing!
nmap <leader>M :Multiedit<CR>
" Clear the word and start editing
nmap <leader>C :Multiedit!<CR>
" Unset the region under the cursor
nmap <silent> <leader>md :MultieditClear<CR>
" Unset all regions
nmap <silent> <leader>mr :MultieditReset<CR>
" Disable all mappings? (So you can set your own)
let g:multiedit_no_mappings = 0
" Reset all regions on InsertLeave when finished?
let g:multiedit_auto_reset = 1
" Disposable marker character (beware characters with strlen > 1 - like
" special/unicode symbols - they don't work).
let g:multiedit_mark_character = '|'
" If no selections are present and you initiate edit mode, should it
" restore the previous regions?
let g:multiedit_auto_restore = 1
The highlight regions can be customized, these are the defaults:
hi default link MultieditRegions Search
hi default link MultieditFirstRegion IncSearch
|Unzip the tarball, and put the files into their respective ~/.vim/* folders. Alternatively, I'd recommend Vundle (https://github.com/gmarik/vundle), then all you'd need is:
Then restart and run:
Click on the package to download.
ip used for rating: 22.214.171.124
||- Fix: when the region goes crazy when the text is at the start of the line (when
len == 0 it would suddenly expand to the length of the line)
- Fix: when the cursor deletes past its boundaries it will leave multiedit
mode and reset your regions
||- New: four new keybinds for adding markers to the start/end of a line or on
the next/previous line
- Changed: auto-removing disposable markers where entering insert mode (had
a strange effect when regions were at the start of a line)
- New: jump between regions with ]m and [m
- Changed: disposable marker will be automatically deleted when entering
- Changed: :MultieditAppendMark and :MultieditPrependMark are merged into
- Changed: the default highlight color for MultieditRegion is now linked to
Search' hl group
- Changed: in visual mode, <leader>mm is not <leader>m (it is still <leader>mm
in normal mode)
- Removed: <leader>ms (sets the region under the cursor to the new
'main' region). <leader>mm and <leader>m will do so implicitly if
a pre-existing region is detected under the cursor
- Removed: <leader>mn and <leader>mp - however, instructions on how to
restore this functionality can be found in |multiedit-settings|
- Fixed: cursor position after editing
- Fixed: old regions weren't saved and couldn't be restored (would throw an
- Fixed: when deleting the main region, the (automatically) assigned new main
region wasn't chosen based on the order in which they were set
- Fixed: errors caused by overlap detection when deleting regions
- General code clean up and refactoring across the board
||- Add :MultieditRestore to restore previous regions (if available). Use with
- Add g:multiedit_auto_restore to control :MultieditRestore being called when
edit mode is initiated without regions specified.
||- Change :Multiedit! functionality to delete word before editing (like
[c]hange command). Use <leader>C to initiate this mode.
- Remove <leader>mw - now <leader>mm does it's job (viw:MultieditAddRegion<CR>)
||- Add :Multiedit! - will move insert caret to the start of the word, instead
of the end. Kep map for this is <leader>I
- Fix automatically adding next/prev occurrence when using :MultieditNextMatch
- Fix :MultieditClear "Key not present" bug
- Fix bug with editing consecutive regions on the same line
- Fix region reordering issue caused by clearing individual regions
- Refactor multiedit#update() completely
- Add :MultieditSet and <leader>ms - allowing you to change the "editable"
||Changed default highlight color for the first region