vim-mode-plus, which is a plugin for Atom editor doesn't have a feature to load vimrc files that are common in Vim editor. Therefore, we need to prepare keymap.cson, which is the keymap configuration file of Atom and init.coffee, which is an initial configuration file of Atom, to assign multiple commands to one command.
I will introduce an example that converts a vimrc file to init.coffee and keymap.cson.
Before Conversion
vimrc
noremap j gj
noremap k gk
noremap <S-j> 10j
noremap <S-k> 10k
noremap <S-h> 10h
noremap <S-l> 10l
After Conversion
init.coffee
atom.commands.add 'atom-text-editor.vim-mode-plus', 'custom:move-left-10', ->
view = atom.views.getView atom.workspace.getActiveTextEditor()
atom.commands.dispatch view, 'vim-mode-plus:set-count-1'
atom.commands.dispatch view, 'vim-mode-plus:set-count-0'
atom.commands.dispatch view, 'vim-mode-plus:move-left'
atom.commands.add 'atom-text-editor.vim-mode-plus', 'custom:move-down-screen-10', ->
view = atom.views.getView atom.workspace.getActiveTextEditor()
atom.commands.dispatch view, 'vim-mode-plus:set-count-1'
atom.commands.dispatch view, 'vim-mode-plus:set-count-0'
atom.commands.dispatch view, 'vim-mode-plus:move-down-screen'
atom.commands.add 'atom-text-editor.vim-mode-plus', 'custom:move-up-screen-10', ->
view = atom.views.getView atom.workspace.getActiveTextEditor()
atom.commands.dispatch view, 'vim-mode-plus:set-count-1'
atom.commands.dispatch view, 'vim-mode-plus:set-count-0'
atom.commands.dispatch view, 'vim-mode-plus:move-up-screen'
atom.commands.add 'atom-text-editor.vim-mode-plus', 'custom:move-right-10', ->
view = atom.views.getView atom.workspace.getActiveTextEditor()
atom.commands.dispatch view, 'vim-mode-plus:set-count-1'
atom.commands.dispatch view, 'vim-mode-plus:set-count-0'
atom.commands.dispatch view, 'vim-mode-plus:move-right'
keymap.cson
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'shift-h': 'custom:move-left-10'
'shift-j': 'custom:move-down-screen-10'
'shift-k': 'custom:move-up-screen-10'
'shift-l': 'custom:move-right-10'
'h': 'vim-mode-plus:move-left'
'j': 'vim-mode-plus:move-down-screen'
'k': 'vim-mode-plus:move-up-screen'
'l': 'vim-mode-plus:move-right'
Top comments (0)