-
Notifications
You must be signed in to change notification settings - Fork 84
Mappings
- VM Leader
- Permanent mappings
- Mouse mappings
- Buffer mappings
- Customization
- Undo and Redo
- Full mappings list
Important: some mappings you can read in this wiki (especially in pages other than this one) may be outdated. This is even more true for pictures, so don't trust pictures for mappings.
Since there are many mappings, most of them are applied as <buffer>
mappings
when VM is started, and removed on exit. VM won't replace buffer mappings that
have already been defined, but it will warn you if it can't map a key because
of this.
To minimize chances for conflicts, a leader that is specific to VM is defined. The default is \\ (two backslashes), but you can change it by setting:
let g:VM_leader = {your VM leader}
All mappings that you see in this wiki that use leader-
will use this leader
instead.
VM insert mode buffer mappings don't use any leader, and will automatically overwrite existing mappings: in this case you'll be warned if some mapping has been replaced. This is so, because wrong insert mode mappings can break your text, rather than leaving you without some functionalities.
Permanent mappings are the ones that are always active. By default the following are created:
C-n | adds a word under cursor, keep pressing to find next occurrence |
C-Down / C-Up | start adding cursors downwards/upwards, skipping empty lines |
S-Right / S-Left | start selecting right or left |
leader-A | select all words in the file |
leader-/ | start regex search |
leader-\ | add cursor at position |
Some other permanent mappings work from visual mode:
C-n | add the visually selected region (as a new pattern) |
leader-a | add the visually selected region (without adding a pattern) |
leader-f | find all current search patterns (from the / register) |
leader-c | create a column of cursors |
You can disable them by setting:
let g:VM_default_mappings = 0
At that point you're left with a single permanent mapping (C-n for selecting words).
Mouse mappings aren't enabled by default, you can do so by setting:
let g:VM_mouse_mappings = 1
They are:
C-LeftMouse | add cursor at clicked position |
C-RightMouse | select clicked word |
M-C-RightMouse | create column of cursors |
After VM has started, buffer mappings become available, and will be unmapped on exit.
These mappings include movement controls (motions, region cyclyng or removal), or commands.
Main controls:
Tab | switch between cursor and extend mode. |
motions | move cursors (cursor mode) or extend selection (extend mode) |
Region cycling and removal:
] | find next |
[ | find previous |
} | goto next |
{ | goto previous |
C-f | fast goto next |
C-b | fast goto previous |
q | skip and go to next |
Q | remove region under cursor |
Operators:
y/d/c | operators at cursors |
m | find operator |
s | select operator (from regions) |
leader-gs | select operator (new region) |
Special commands:
R | Replace pattern in regions |
S | Surround (requires plugin) |
C-a | Increase numbers |
C-x | Decrease numbers |
M-S ⇐ ⇒ | Text move left and right |
Commands that use leader
:
leader-c | Change case setting |
leader-w | Toggle whole word search |
leader-t | Transpose |
leader-a | Align cursors |
leader-s | Split regions with pattern |
leader-f | Filter regions with pattern |
leader-e | Transform regions with expression |
leader-r | Rewrite last pattern |
leader-m | Merge regions |
leader-d | Duplicate regions |
leader-" | Show VM registers |
leader-` | Tools menu |
leader-C | Case conversion menu |
leader-S | Search menu |
leader-M | Toggle Multiline |
leader-Space | toggle VM mappings |
leader-Enter | toggle 'Only' mode |
More commands that use leader
:
leader-z | Run Normal |
leader-v | Run Visual |
leader-x | Run Ex |
leader-Z | Run Last Normal |
leader-V | Run Last Visual |
leader-X | Run Last Ex |
leader-@ | Run Macro |
leader-- | Shrink regions by 1 |
leader-+ | Enlarge regions by 1 |
leader-< | Align by Char |
leader-> | Align with Regex |
leader-n | Numbers (insert) |
leader-N | Numbers (append) |
leader-0n | Numbers (insert) (start from 0) |
leader-0N | Numbers (append) (start from 0) |
You can customize a lot of the default mappings.
If you want to add/change a mapping in your vimrc, first initialize the dictionary:
let g:VM_maps = {}
Many mappings are not enabled by default, but you could add them to your vimrc. For example:
let g:VM_maps = {}
let g:VM_maps['Find Under'] = '<C-d>' " replace C-n
let g:VM_maps['Find Subword Under'] = '<C-d>' " replace visual C-n
let g:VM_maps["Select Cursor Down"] = '<M-C-Down>' " start selecting down
let g:VM_maps["Select Cursor Up"] = '<M-C-Up>' " start selecting up
If you instead want to disable a specific mapping, set it to an empty string:
let g:VM_maps['Find Under'] = '' " disable find under
If you want to duplicate some mappings, instead of replacing them, you can use
the g:VM_custom_remaps
option:
" use <c-p> to find backwards, <c-s> to skip a match
let g:VM_custom_remaps = {'<c-p>': '[', '<c-s>': 'q'}
Note that if you use ,
as VM_leader
, you should remap the ,
VM key, because
otherwise you'll have a delay when using ,
. For example:
let g:VM_leader = ','
let g:VM_maps['Motion ,'] = ',,'
This feature is not yet enabled by default: with it you can undo/redo changes made in VM, and the regions will be restored as well. You have to map the commands to make it work.
let g:VM_maps["Undo"] = 'u'
let g:VM_maps["Redo"] = '<C-r>'
Mappings with \\
are meant prefixed by the VM_leader
. These permanent
mappings are enabled by default:
let g:VM_maps['Find Under'] = '<C-n>'
let g:VM_maps['Find Subword Under'] = '<C-n>'
let g:VM_maps["Select All"] = '\\A'
let g:VM_maps["Start Regex Search"] = '\\/'
let g:VM_maps["Add Cursor Down"] = '<C-Down>'
let g:VM_maps["Add Cursor Up"] = '<C-Up>'
let g:VM_maps["Add Cursor At Pos"] = '\\\'
let g:VM_maps["Visual Regex"] = '\\/'
let g:VM_maps["Visual All"] = '\\A'
let g:VM_maps["Visual Add"] = '\\a'
let g:VM_maps["Visual Find"] = '\\f'
let g:VM_maps["Visual Cursors"] = '\\c'
You can disable them by setting:
let g:VM_default_mappings = 0
These permanent mappings are not enabled by default. The mapping provided is an example:
let g:VM_maps["Select Cursor Down"] = '<M-C-Down>'
let g:VM_maps["Select Cursor Up"] = '<M-C-Up>'
let g:VM_maps["Erase Regions"] = '\\gr'
let g:VM_maps["Mouse Cursor"] = '<C-LeftMouse>'
let g:VM_maps["Mouse Word"] = '<C-RightMouse>'
let g:VM_maps["Mouse Column"] = '<M-C-RightMouse>'
These buffer mappings are enabled by default:
let g:VM_maps["Switch Mode"] = '<Tab>'
let g:VM_maps["Find Next"] = ']'
let g:VM_maps["Find Prev"] = '['
let g:VM_maps["Goto Next"] = '}'
let g:VM_maps["Goto Prev"] = '{'
let g:VM_maps["Seek Next"] = '<C-f>'
let g:VM_maps["Seek Prev"] = '<C-b>'
let g:VM_maps["Skip Region"] = 'q'
let g:VM_maps["Remove Region"] = 'Q'
let g:VM_maps["Invert Direction"] = 'o'
let g:VM_maps["Find Operator"] = "m"
let g:VM_maps["Surround"] = 'S'
let g:VM_maps["Replace Pattern"] = 'R'
let g:VM_maps["Tools Menu"] = '\\`'
let g:VM_maps["Show Registers"] = '\\"'
let g:VM_maps["Case Setting"] = '\\c'
let g:VM_maps["Toggle Whole Word"] = '\\w'
let g:VM_maps["Transpose"] = '\\t'
let g:VM_maps["Align"] = '\\a'
let g:VM_maps["Duplicate"] = '\\d'
let g:VM_maps["Rewrite Last Search"] = '\\r'
let g:VM_maps["Merge Regions"] = '\\m'
let g:VM_maps["Split Regions"] = '\\s'
let g:VM_maps["Remove Last Region"] = '\\q'
let g:VM_maps["Visual Subtract"] = '\\s'
let g:VM_maps["Case Conversion Menu"] = '\\C'
let g:VM_maps["Search Menu"] = '\\S'
let g:VM_maps["Run Normal"] = '\\z'
let g:VM_maps["Run Last Normal"] = '\\Z'
let g:VM_maps["Run Visual"] = '\\v'
let g:VM_maps["Run Last Visual"] = '\\V'
let g:VM_maps["Run Ex"] = '\\x'
let g:VM_maps["Run Last Ex"] = '\\X'
let g:VM_maps["Run Macro"] = '\\@'
let g:VM_maps["Align Char"] = '\\<'
let g:VM_maps["Align Regex"] = '\\>'
let g:VM_maps["Numbers"] = '\\n'
let g:VM_maps["Numbers Append"] = '\\N'
let g:VM_maps["Zero Numbers"] = '\\0n'
let g:VM_maps["Zero Numbers Append"] = '\\0N'
let g:VM_maps["Shrink"] = "\\-"
let g:VM_maps["Enlarge"] = "\\+"
let g:VM_maps["Toggle Block"] = '\\<BS>'
let g:VM_maps["Toggle Single Region"] = '\\<CR>'
let g:VM_maps["Toggle Multiline"] = '\\M'