I'm t9md
- My editor history: Vim > Emacs > Vim > Atom
- Emacs's limitless extensibility plant never give up sprit to me and it also made me editor addict.
- Vim plugins: choosewin, qickhl, smalls, textmanip, vim-chef, and more
- Atom packages: vim-mode-plus, narrow, quick-highlight, cursor-history, and more..(over 30 pkgs!).
Are you familiar with this endless editor tuning loop?.
- Frustration > Yes I can improve it > Ya I did it!! Oh, I found another frustration point > oh, I've spent too much hours!.
What is the vim-mode-plus(VMP)?
- It's Atom editor package which provides vim keybinding and plus more.
- This is fork of vim-mode created by GitHub , they now deprecated it in favor of vmp.
Version | Date | Event |
---|---|---|
v0.0.0 | 2015-08-01 | fork GitHub's vim-mode |
v0.1.1 | 2015-09-28 | 1st public |
v1.13.0 | 2017-10-27 | 185th release in 818 days (2 years + 3 months) |
AVG. 1 release / 4.5 days !!
I'm still keeping high pace release cycle as first year of vmp.
Who use vmp?
- Jordan Walke(ReactJS, ReasonML)
- Cheng Lou(ReactMotions, ReasonML)
- Richard Feldman(Elm book author, evangelist)
- Kent C Todd(Author of lots of npm modules and more).
- Michael Jackson(React Router, React Training)
- Ryan Florence(React Router, React Training)
Some says vmp is the best vim emulator.
IMO, maybe it's because of precise cursor placement.(e.g. cursor placement after undo or redo operation).
What I will talk today
Part1. Understand editing in Vim
- What is editing in Vim
- How it's implemented and executed
- What is Motion, TextObject and Operator
Part2. vmp's unique features
- UX improvement
- Cursor placement
- One key TextObject
- Occurrence
Part1. Understand editing in Vim
What is editing in Vim?
Why can your j
keystroke move-down cursors
Operation's life in stack on operationStack
Motion, TextObject, Operator
Motion: j
, k
, {
, g g
...
- Move cursor from here to there.
- When used as TARGET, select here-to-there.
TextObject: i p
, i w
, a W
...
- Select text range, always used as TARGET.
- Select same range as long as cursor is within that range
i w
select same word as long as cursor is within that word.
Operator: d
, c
, y
...
- Mutate TARGET
- Always require TARGET. "I will wait until I get target!".
Summary
Editing is to transform text by mutation.
You build mutation instruction through keystroke.
Each keystroke invoke one of Operator, Motion or TextObject.
Formula: Mutation = Operator + Target(= Motion or TextObject)
Part2. VMP's unique features
DEMO session
- Select operator
- TransformString operators
- Edge motion
- Occurrence
- Persistent selection
- Practical use of occurrence etc...
Flash target
- vmp flashes an operator's target and also flashes changes on
undo
,redo
. - When you type
y i p
, it flashesi p
range with CSS keyframe animation. - With flash, you can be more confident for your operation.
UI feedback on surround
- Surround is difficult for me.
- Because I have to type many keystrokes without mistake, without any UI feedback.
y s i w (
: surround(y s
) inner-word(i w
) with(
.
vmp gives proper UI feedback to make surround easy to use, easy to understand
- Select target immediately after target was provide(
i w
) and before you input final surround-char. - When
change-surround
, it shows char will be change at hover indicator.
- Select target immediately after target was provide(
This GIF is after you type
c s "
and before you input final'
Tunable f
behavior and flash find-char.
f
is difficult. Where to stop next?.- With flashing finding-char, you can predict where to stop next.
- I like all
vim-seek
,clever-f
andvim-sneak
, I want all of it's goodness.- Make it configurable to
find across lines
,number of chars to find
,auto confirm by timeout
,reuse f as ;
... - You can tune vmp's
f
as you like.
- Make it configurable to
Eliminate unwanted cursor move
- What if cursor is not moved after
y i p
?- In pure-Vim, cursor is moved to start of paragraph.
- IMO, moving cursor after operator is unwanted side-effect.
- vmp introduces various stayOnXXX configuration and all have enabled by default.
- In pure-Vim,
stayOnVerticalMotion
+stayOnDelete
is doable by:set startofline=false
- In pure-Vim,
stayOnXXX configurations
- Keep cursor positions after operator
y i p
,d d
,g U i p
..stayOnTransformString
,stayOnYank
,stayOnDelete
,stayOnOccurrence
- Keep column when selecting TextObject
v i p
,v i i
..stayOnSelectTextObject
- keep column on vertical motion
g g
,G
...stayOnVerticalMotion
One-key for VIP(Very ImPortant) TextObject
- You can type
y p
instead ofy i p
. How many times have you ever typedi p
in your life!? - Why? Some keys are freely available in operator-pending-mode.
- Since Operator is waiting for Target(Motion or TextObject) only. Remember
Operator + Target
rule?. - So
Operator + Operator
keystroke(y d
,d p
...) makes no sense, OK to re-map.- One exception, same-operator-twice(
d d
,y y
...) keystrokes have special meaning.
- One exception, same-operator-twice(
Occurrence
- Noticed patterns in coding. I'm repeating same operation on same keyword again and again.
- With
occurrence
, you can bulk apply operator to all occurrences of keyword within target. - You can edit more declaratively than imperatively, also can reduces need of
.
repeat.
Occurrence: How it works
Occurrence is not difficult, technically it's marker edit
- Mark keyword under cursor then edit as in normal way.
- You can mark keyword by either of following way
- operator-modifier:
o
(word) andO
(subword).(e.g.d o p
,c O z
) preset-occurrence
command:g o
andg O
. I'm remapping tom
andM
locally.
- operator-modifier:
- Mark keyword by
g o
org O
(subword) - Select visually
c
to change,I
to insert at startA
to append to end of occurrence.
Advice to improve vim-skill
Understand this formula. Editing = Operator + Target(Motion or TextObject).
- Install
Operator + Target
mental model into your brain by shouting loudly while typing. y
("Operator"!!)i p
("Target!!")
- Install
Pick and master from high-return Motion, TextObject first.
- Motion:
g g
,G
,[
,]
(VMP only) - TextObjet:
i p
,i w
,i z
(VMP only),i ,
(VMP only)
- Motion:
Use it in daily editing.
Repeat, repeat, repeat! Till your finger moves without THINKING.
- Vim:
y i p
,y i p
,y i p
...c i p
,c i p
...d i p
... - Vim:
y i ,
,y i ,
,y i ,
...c i ,
,c i ,
...d i ,
... - vmp shorthand:
y p
,y p
,y p
...c p
,c p
...d p
... - vmp shorthand:
y ,
,y ,
,y ,
...c ,
,c ,
...d ,
...
- Vim:
Gradually increase TextObject, Motion of daily use.
: VMP is the most ambitious vim emulator in the world(IMO!).
- Bundled so many non-default Motion, TextObject, Operator.
- Introduces new editing concept: e.g.
occurrence
,persistent-selection
. - UX improvement to make Vim easy to use, easy to understand.
- vmp is NOT aiming to become a perfect Vim emulator(no interest!).
- My mental stance is just borrowing favorite Vim features.
- Motivation is to experiment what-if ideas with hackable editor(Atom!).
- Ideas comes from frustration I encounter in daily vmp-dev. Endless feedback loop!
- I'm really SERIOUS for vmp, but vmp is NOT STRICT.