sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

vim-multiedit : Multi-selection editing for vim, inspired by Sublime Text

 script karma  Rating 9/3, Downloaded by 1692    Comments, bugs, improvements  Vim wiki

created by
Henrik Lissner
script type
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
install details
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:

    Bundle "hlissner/vim-multiedit"

Then restart and run:


GITHUB: https://github.com/hlissner/vim-multiedit

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-multiedit.tar.gz 2.0.2 2013-03-28 7.0 Henrik Lissner - 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
vim-multiedit.tar.gz 2.0.1 2013-03-26 7.0 Henrik Lissner - 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)
vim-multiedit.tar.gz 2.0.0 2013-03-25 7.0 Henrik Lissner 2013-03-25 [2.0.0]
- New: jump between regions with ]m and [m
- Changed: disposable marker will be automatically deleted when entering
  insert mode
- Changed: :MultieditAppendMark and :MultieditPrependMark are merged into
  :MultieditAddMark [ia]
- 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
vim-multiedit.tar.gz 1.1.3 2013-03-11 7.0 Henrik Lissner - 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.
vim-multiedit.tar.gz 1.1.2 2013-03-11 7.0 Henrik Lissner - 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>)
vim-multiedit.tar.gz 1.1.1 2013-03-11 7.0 Henrik Lissner - 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
  and :MultieditPreviousMatch
vim-multiedit.tar.gz 1.1.0 2013-03-10 7.0 Henrik Lissner 2013-03-10 [1.1.0]
- 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"
vim-multiedit.tar.gz 1.0.1 2013-03-09 7.0 Henrik Lissner Changed default highlight color for the first region
vim-multiedit.tar.gz 1.0 2013-03-09 7.0 Henrik Lissner Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo