-
Notifications
You must be signed in to change notification settings - Fork 109
YouDontKnowVimModePlus
- Pure Vim moves the cursor as a side effect of operator, vim-mode-plus doesn't.
- Maximize current pane
- IncrementalSearch
- Smooth Scroll for scroll motion
- Per operation granular keymap scope
-
making
I
andA
is available in all visual mode - Motions
- Operator
- TextObject
- Persistent Selection
- Narrow mode in visual-mode
This document quickly introduces notable vim-mode-plus's features which tend to be unnoticed.
In pure Vim, each time an operator finished, cursor is moved to start of target. I wanted to change this behavior, I wanted the cursor position to remain unchanged after the operator finished.
In pure-Vim
- After you
yank
, cursor position is set at start position of target. - So
y i p
moves cursor to start position of paragraph.y
in visual-mode moves cursor to start position of visual area. - After you
d d
, your cursor position is set at start of non-empty-char of next line of deleted line. - Like this way, basically when you execute some operator, cursor position automatically moved.
In vim-mode-plus user can disable this unwanted-side-effect(at least for me) by enabling following configuration.
-
stayOnTransformString
: Affects all string transformation operator such assurround
,g U
-
stayOnYank
: Cursor remains at same position aftery
. -
stayOnDelete
: Cursor remains at same position afterd
.
The one good effects of moving cursor to start of target area after operation finished is that user can understand that operator was successfully executed.
Without moving cursor, user have less confident whether their keystroke is handled or not.
So vim-mode-plus adds flashOnOperate
configuration, which is enabled by default.
This feature adds short-time-blinking-highlight to the target range of operator.
For example, y i p
flashes, inner-paragraph
in short duration. So user can understand what area is yanked visually without depending on movement happened as an side effect of operator.
-
vim-mode-plus:maximize-pane
:cmd-enter
in macOS. Other OS have no default keymap.
- Enable it from setting-view. The
/
and?
become incremental-search. -
tab
,shift-tab
allow you visit matching keyword without confirming. -
ctrl-r ctrl-w
to insert cursor-word to search-input. - Your input is treated as regular expression. By starting space(
- Following special feature relating to OccurrenceModifier is available.
-
ctrl-cmd-c
: change matching pattern in-bulk. -
cmd-d
: select matching keyword at once. -
cmd-o
: add preset-occurrence for matching keyword.
-
- Enable it from setting-view.
- Can enable/disable for full-scroll(
ctrl-f
,ctrl-b
) or half-scroll(ctrl-d
,ctrl-u
) independently.
- When some operation is waiting for user input, typically in
operator-pending
. - You can have specific keymap only effective in this condition(specific operator is waiting for user input).
- If using general
operator-pending
scope conflicts other keymap, use this granular, narrower scope.
# yank/delete paragraph by `y p`, `d p`
'atom-text-editor.vim-mode-plus.yank-pending, atom-text-editor.vim-mode-plus.delete-pending':
'p': 'vim-mode-plus:inner-paragraph'
'/': 'vim-mode-plus:inner-comment'
# So that Ican toggle comment for paragraph by `g / /`
'atom-text-editor.vim-mode-plus.toggle-line-comments-pending':
'/': 'vim-mode-plus:inner-paragraph'
vmp bundled great vim-niceblock like feature. Not fully compatible with vim-niceblock though, I intentionally choose current vmp's behavior.
In visual-block mode(vB
), I
and A
is already useful you know.
Why not making I
and A
in other visual-mode(vC
, vL
) also useful.
So this enhancement change behavior of g I
, I
, A
in mode vC
, vL
.
Insert at first column in all mode.
mode | action |
---|---|
n |
first column of cursor line |
vC |
first column of each selected lines (cursor multiplied) |
vL |
first column of each selected lines (cursor multiplied) |
vB |
first column of each selected lines |
Insert at first-character-of-line(FCOL) in n
and vL
.
Insert at start-of-selection-column in vC
and vB
.
mode | action |
---|---|
n |
insert-at-FCOL of cursor line |
vL |
insert-at-FCOL for each selected lines (cursor multiplied) |
vC |
Shorthand of ctrl-v I (vB in this table) (cursor multiplied) |
vB |
insert-at-start-of-selection-column for each selected lines |
Insert at EOL in n
and vL
.
Insert at end-of-selection-column in vC
and vB
.
mode | action |
---|---|
n |
insert-at-EOL of cursor line |
vL |
insert-at-EOL for each selected lines (cursor multiplied) |
vC |
Shorthand of ctrl-v A (vB in this table) (cursor multiplied) |
vB |
insert-at-end-of-selection-column for each selected lines |
- MoveUpToEdge, MoveDownToEdge:
[
,]
is mapped by default (aggressive decision).
-
ctrl-a
,ctrl-x
: To increment/decrement number. -
g ctrl-a
,g ctrl-x
: Invisual-mode
, all number occurrence in visual-area is treated as group and re-number it by incrementing or decrementing from first number. In pure Vim first number is also incremented, but in vim-mode-plus first number is always treated as base number. You can specify a count to indicate steps of each increment. So3 g ctrl-a
increments 3 on each increment steps.
-
URLencode, CamelCase, DashCase etc etc etc.. Many common string transformation is already bundled in vim-mode-plus.
-
TransformString: is parent of many string transformation operator
-
Some don't have default keymap, and remembering all keymap is impossible?
-
TransformWordBySelectList: is for you. it allows transformation operator from select-list(No default keymap, I map
ctrl-s
to to it).- Place cursor to
camel-case
. -
ctrl-s
(in-my-case) show menu, choose string transformation operator like Camelize. -
i w
: to targetinner-word
-
inner-word
is transformed toCamelCase
- Place cursor to
-
Surround: is bundled. No default keymap.
- ChangeSurround
- ChangeSurroundAnyPair: Auto detect pair char. In most case, this is better than
ChangeSurround
which manually specify pair char. - DeleteSurround
- DeleteSurroundAnyPair: Auto detect pair char. In most case, this is better than
DeleteSurround
which manually specify pair char.
-
ReplaceWithRegister: No default keymap. but I use very-very frequently.
- With combination of preset-occurrence and persistent-selection. You can intuitively replace keyword with text in register.
-
Sort: No default keymap. I map it
g s
-
Reverse: No default keymap. I map it
g r
-
ToggleLineComments:
-
g /
is default keymap. -
g / i p
to comment out paragraph. - You can remove comment by
g / i /
regardless of cursor position. Thei /
is comment text-object, which selects only commented rows.
-
- Function:
i f
(body only exclude parameters part) anda f
(whole function). - Indentation:
i i
(same-or-deeper indent level) anda i
(blank-row or same-or-deeper). - CurrentLine:
i l
(line text exclude trailing/reading white space),a l
(whole line). - VisibleArea:
i v
(visible screen area),a v
(same asi v
). - Entire:
i e
(Whole buffer),a e
(same asi e
). - Fold:
i z
(fold body excluding fold start row),a z
(include start row of fold). - Comment:
i /
(commented area),a /
(same asi /
).
- In visual-mode,
enter
make current selection persistent-selection -
escape
to clear persistent-selection - By default
persistent-selection
is treated as part of selection. - So all operator apply it's mutation to
persistent-selection
if it exists. - Use
autoSelectPersistentSelectionOnOperate
config option to disable this. - Since Atom's
cmd-d
is not good at skipping multiple instances, making selection persistent byenter
is easier.
- When selection was multi-lines
is-narrowed
is automatically set. - In this mode some special shortcut is available
-
cmd-d
: to select cursor word intersecting selection. -
ctrl-cmd-c
: to change cursor-word intersecting selection in-bulk. - In
is-narrowed
selection stateg o
add preset-occurrence at cursor position, then user can continue extending visual-area. - When selection was not multi-line, it is NOT
is-narrowed
,g o
add preset-occurrence for keyword which is currently selected.