Help us understand the problem. What is going on with this article?

vim-mode-plus for Atom editor vimconf-2016

More than 3 years have passed since last update.

vim-mode-plus for Atom editor vimconf-2016

by t9md
1 / 16

I'm t9md

t9md__t9md_.png Presentation1.png

  1. Was normal Vim user
  2. Was advanced Emacs user.
  3. Was advanced Vim user
    • vim-chef, vim-xmpfilter, textmanip, choosewin, quickhl, smalls...
  4. Am Atom with vim-mode-plus user
    • vim-mode-plus, cursor-history, open-this, quick-highlight, project-folder...

What makes me editor addict :syringe: is difficulties and limitless enhanceability of Emacs.


What is the vim-mode-plus?

Started by forking vim-mode maintained by GitHub :octocat:
- Forked at 2015.08
- Public release at 2015.09.28
- Now 104 releases(!!) from initial release at 2016.11.04(about 1 release/4 days)
- Now de facto vim keybinding in Atom?

vim-mode's README was updated yesterday(2016.11.04)

Current Status - DEPRECATED in favor of vim-mode-plus

  • It's honor to be used by really talented programmers(jordwalke, chenglou, rtfeldman).
  • Happy to be mentioned in JavaScriptAir 034

What I did from when I forked

  • :art: Refactoring
    • Rewrote every lines of codes. Greatly reduced complexity.
  • :gift: Add lot's of new features:
    • incremental-search
    • visual-block-mode
    • surround
    • any-pair text-object
    • occurrence operator-modifier
    • persistent-selection
  • :bow: Off course, thanks to great vim-mode
    • Sincerely, I feel I couldn't do anything without original vim-mode.
  • Gifs

History of commit graphs

graphs

Contributors_to_t9md_atom-vim-mode-plus.png


High speed tutorial from beginner to expert in 7 steps

High speed tour from beginner to expert in 7 steps

[Vim/vim-mode-plus for Atom] 秒速で初心者からエキスパートになる。 たった7ステップで。


Editing in the vim-world

The editing is transforming state of text by mutation.
initial-text -> mutate -> final-text
Mutating text with operator and target by telling vim to "do what on which target".

Subjects, Verbs and Objects basic operation unit

  • Subject is You.
  • Verb: is Operator
    • Specify what to do. The verb requires an object(=target).
    • Do mutation(Delete :scissors:, Yank :clipboard:, CamelCase :camel:)
  • Objects: is Target(Motion or TextObject)
    • Specify where, which to apply an operators on.
    • i w(inner-word text-object), j(from-here-to-next-line)

How operation-stack of vim-mode-plus is working.


Motion is complete?

Photo_04-11-2016__4_15_25_jpg.png
Photo_04-11-2016__4_15_25_jpg.png
Photo_04-11-2016__4_15_25_jpg.png


Operator is complete?

Photo_04-11-2016__4_15_37_jpg.png
Photo_04-11-2016__4_15_37_jpg.png
Photo_04-11-2016__4_15_37_jpg.png

class DeleteToLastCharacterOfLine extends Delete
  @extend()
  target: 'MoveToLastCharacterOfLine'
  execute: ->
    if @isMode('visual', 'blockwise')
      swrap.setReversedState(@editor, false)
    super

Operation life in operation-stack

execute operation when it's complete!

Photo_04-11-2016__4_18_44_jpg.png

OperationStack code

    top = @peekTop()
    if top.isComplete()
      @execute(@stack.pop())
    else
      if @mode is 'normal' and top.isOperator()
        @modeManager.activate('operator-pending')

      # Temporary set while command is running
      if commandName = top.constructor.getCommandNameWithoutPrefix?()
        @addToClassList(commandName + "-pending")

vim-mode-plus original features

YouDontKnowVimModePlus

  • Maximize current pane
  • Incremental search
  • flashOnOperate and flashOnUndoRedo :sparkles:
  • StayOn family(stayOnTransformString, stayOnYank, stayOnDelete) :sparkles:
  • Motions: MoveDownToEdge, MoveToNextNumber, MoveToNextString
  • TextObject: AnyPair, Indentation, Entire(All), Fold, Function, Comment
  • Operator: Lots of string transformer(Sort, CamelCase, SnakeCase, Surround, ToggleLineComments, ReplaceWithRegister etc..)
  • Operator: Meta string transformer (TransformStringBySelectList).
  • Narrowed selection. cmd-d(select-occurrence), ctrl-cmd-c(change-occurrence).
  • Super granular keymap scopes(e.g. mapping only effective when toggle-line-comments-pending)
  • Persistent-selection: works as like normal visual-selection but you can make selection persist.

Keep cursor position by operator.

  • Side-effect-less operator by stayOnYank, stayOnDelete and stayOnTransformString
  • In pure-Vim, y i p move cursor to start of yanked area.
  • I want cursor move only when I said so. Don't move unless I said so :gun:.

stayOnOperate

  • But cursor movement convinces user the success of an operator.
  • Just dont-move-cursor is not enough, flashOnOperate :flashlight: compliment user's confidence.

Occurrence modifier, preset-occurrence, persistence-selection

  • As like you can force-wise of operator by d v j, o modifies operator's behavior to works on occurrences within target.
  • A preset-occurrence allows you to set occurrence preliminarily.
  • ctrl-o in incremntal-search allows you to set preset-occurrence by regex pattern
    • e.g. / ^ # * $ ctrl-o g U i e uppercases all lines starts with #.
  • Also a persistent-selection allows you to pre-specify a target of operator.

Sometimes, replacing single-char in bulk is faster :dash: than repeating operator.

Repeat(.) delete-surround

vimconf-2.gif

delete-surround with multiple cursor

vimconf-3.gif

preset-occurrence for single quote ' then apply delete operator.

vimconf-4.gif


So what am I doing in vim-mode-plus?

  • :rotating_light: :warning: vim-mode-plus is not trying to be complete-Vim

    • Impossible and no motivation for that.
    • Atom is NOT Vim.
  • :rocket: vim-mode-plus is aggressively evaluating how effective-editing-would-be.

    • How is it like when xxx is yyy.
    • Is zzz feature is really practically(not conceptually) useful?
  • :thought_balloon: :moyai: :zzz: Thinking about Vim deeply further than I was pure-Vim user.

    • And always found pure-Vim's really careful and maniac decision for developer's intuitiveness/productivities.

:tada: :tada: Thanks!! :tada: :tada:

Vim!! You are great!

Atom! You are great!

Vim-mode! Without you, I don't think I could create vim-mode-plus from scratch.

Japanese Vim community! Love friendly atmosphere and lots of super aggressive/good plugin authors and contributers to core.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away