Skip to content
Nikolai Borisik edited this page Jan 13, 2017 · 37 revisions

In insert-mode, hitting escape to close autocomplete popup result in normal-mode, but want to remain in insert-mode.

#339

By default escape always escape insert-mode regardless of autocomplete's popup.
To change default behavior of escape, set following keymap in your keymap.cson.

'atom-text-editor.vim-mode-plus.insert-mode.autocomplete-active':
  'escape': 'autocomplete-plus:cancel'

Or you can use different keymap to explicitly close autocomplete-plus's popup like bellow.

'atom-text-editor.vim-mode-plus.insert-mode.autocomplete-active':
  'ctrl-g': 'autocomplete-plus:cancel'

Hide indent-guide on last buffer row.

vim-mode-plus prevents move cursor on Atom's last buffer row.
When you have enabled editor.showIndentGuide, it shows indent-guide on last buffer row where vmp don't allow to move.

This is very counter intuitive.

By setting following style on you styles.less you can hide indent-guide on last buffer row.

atom-text-editor::shadow div.lines div:last-child .line:last-child {
  .indent-guide {
    box-shadow: none;
  }
}

Highlight cursor-line differently depending on current mode.

Set following code in your styles.less and modify it as you want.

.cursor-line-background(@mode, @color) {
  atom-text-editor.vim-mode-plus.@{mode}.is-focused {
    & .lines .line.cursor-line {
      background-color: @color
    }
  }
}
.cursor-line-background(normal-mode, fadeout(gray, 80%));
.cursor-line-background(insert-mode, fadeout(green, 80%));
.cursor-line-background(operator-pending-mode, fadeout(yellow, 80%));

Define command for multiple keystroke.

Background:

#265 #266

Use keystroke

How can I use ctrl-w to close pane?

ctrl-w is used as prefix key for many commands and Atom keymap currently not providing easy way to disable prefixed key in bulk. So, you have to

  1. Disable each keymap by mapping it to unset!.
  2. Then map ctrl-w to core:close which close pane.

For step1, you have to find all the keymaps which use ctrl-w as prefix by observing key-binding-resolver(cmd-.).
You can use disable-keybindings to make this process easier.

Here is example when you don't use disable-keybindings package with vim-mode-plus v0.44.1.

'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  # Disable all the keymap defined in keymaps/vim-mode-plus.cson in this scope
  'ctrl-w ctrl-h': 'unset!'
  'ctrl-w h': 'unset!'
  'ctrl-w left': 'unset!'
  'ctrl-w ctrl-l': 'unset!'
  'ctrl-w l': 'unset!'
  'ctrl-w right': 'unset!'
  'ctrl-w ctrl-k': 'unset!'
  'ctrl-w k': 'unset!'
  'ctrl-w up': 'unset!'
  'ctrl-w ctrl-j': 'unset!'
  'ctrl-w j': 'unset!'
  'ctrl-w down': 'unset!'
  'ctrl-w ctrl-w': 'unset!'
  'ctrl-w w': 'unset!'
  'ctrl-w ctrl-p': 'unset!'
  'ctrl-w p': 'unset!'
  'ctrl-w ctrl-c': 'unset!'
  'ctrl-w c': 'unset!'
  'ctrl-w ctrl-v': 'unset!'
  'ctrl-w v': 'unset!'
  'ctrl-w ctrl-s': 'unset!'
  'ctrl-w s': 'unset!'
  'ctrl-w ctrl-q': 'unset!'
  'ctrl-w z': 'unset!'
  'ctrl-w q': 'unset!'

  'ctrl-w': 'core:close'

Escape from insert-mode by typing jk quickly.

Esc is a little far from home position, and ctrl-[ is difficult to type.

'atom-text-editor.vim-mode-plus.insert-mode':
  'j k': 'vim-mode-plus:activate-normal-mode' # jk to escape

Clear multiple selection when escaped from insert mode

In vim-mode-plus, visual-block mode is achieved by using multiple-cursor(=or selection).
When you enter insert mode from visual-block mode then escaped from insert mode, multiple cursors created in visual-block mode is not cleared.
This behavior diff against pure Vim is by intention, by keeping multiple cursor, you can continue multi-cursor operation in normal mode.

If you don't want this default behavior, paste following code snippet in your init.coffee.
It clear multiple cursor at the timing you exit from insert mode.

consumeService = (packageName, providerName, fn) ->
  disposable = atom.packages.onDidActivatePackage (pack) ->
    return unless pack.name is packageName
    service = pack.mainModule[providerName]()
    fn(service)
    disposable.dispose()

consumeService 'vim-mode-plus', 'provideVimModePlus', (service) ->
  {observeVimStates} = service

  observeVimStates (vimState) ->
    vimState.modeManager.onDidDeactivateMode ({mode}) ->
      if mode is 'insert'
        vimState.editor.clearSelections()

Use system-clipboard only when you use space as leaderkey

From v0.66.0

  • You want y y to save unnamed(") register. vim-mode-plus local register not shared by other apps.

  • But when you type space y y, save to system-clipboard.

  • Also you want all y or d behave in same mannter. (space d d to save to system-clipboard).

  • keymap.cson

'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  'space': 'vim-mode-plus:set-register-name-to-*'

Delete without saving to register.

From v0.66.0

You can use blackhole register(_), so " _ d d keystroke delete current line without saving register.
But you want shorten " _ keystoke easy-to-type.

  • keymap.cson
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  '\\': 'vim-mode-plus:set-register-name-to-_'

With above keymap.

  • \ d d delete current line without updating register.
  • All register suppoted command works in same way.(e.g. \ C)
Clone this wiki locally