diff --git a/README.md b/README.md index 9a85942f..3fdc295d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ run `apm install vim-mode` from the command line. ### Current Status -Sizable portions of Vim's command mode work as you'd expect, including +Sizable portions of Vim's normal mode work as you'd expect, including many complex combinations. Even so, this package is far from finished (Vim wasn't built in a day). diff --git a/docs/overview.md b/docs/overview.md index 3ff18940..e2a88a0e 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -1,6 +1,6 @@ ## Overview -* There are only currently two modes, command mode and insert mode. +* There are only currently two modes, normal mode and insert mode. * Motions have repeat support, `d3w` will delete three words. * Insert mode can be entered using `i`, `I`, `a`, `A`, `o`, or `O`. * Registers are a work in progress diff --git a/keymaps/vim-mode.cson b/keymaps/vim-mode.cson index aac4b4d2..87f69625 100644 --- a/keymaps/vim-mode.cson +++ b/keymaps/vim-mode.cson @@ -1,14 +1,14 @@ 'atom-text-editor.vim-mode': - 'escape': 'vim-mode:reset-command-mode' - 'ctrl-c': 'vim-mode:reset-command-mode' - 'ctrl-[': 'vim-mode:reset-command-mode' + 'escape': 'vim-mode:reset-normal-mode' + 'ctrl-c': 'vim-mode:reset-normal-mode' + 'ctrl-[': 'vim-mode:reset-normal-mode' -'atom-text-editor.vim-mode:not(.command-mode)': - 'escape': 'vim-mode:activate-command-mode' - 'ctrl-[': 'vim-mode:activate-command-mode' +'atom-text-editor.vim-mode:not(.normal-mode)': + 'escape': 'vim-mode:activate-normal-mode' + 'ctrl-[': 'vim-mode:activate-normal-mode' -'.platform-darwin atom-text-editor.vim-mode:not(.command-mode)': - 'ctrl-c': 'vim-mode:activate-command-mode' +'.platform-darwin atom-text-editor.vim-mode:not(.normal-mode)': + 'ctrl-c': 'vim-mode:activate-normal-mode' 'atom-text-editor.vim-mode.insert-mode': 'ctrl-w': 'editor:delete-to-beginning-of-word' @@ -138,7 +138,7 @@ '8': 'vim-mode:repeat-prefix' '9': 'vim-mode:repeat-prefix' -'atom-text-editor.vim-mode.command-mode': +'atom-text-editor.vim-mode.normal-mode': 'i': 'vim-mode:activate-insert-mode' 'v': 'vim-mode:activate-characterwise-visual-mode' 'V': 'vim-mode:activate-linewise-visual-mode' @@ -219,7 +219,7 @@ 'a (': 'vim-mode:select-around-parentheses' 'a )': 'vim-mode:select-around-parentheses' 'a b': 'vim-mode:select-around-parentheses' - 'x': 'vim-mode:reset-command-mode' + 'x': 'vim-mode:reset-normal-mode' 'atom-text-editor.vim-mode.visual-mode': 'x': 'vim-mode:delete' diff --git a/lib/operators/general-operators.coffee b/lib/operators/general-operators.coffee index 91ab2915..4ee94ad6 100644 --- a/lib/operators/general-operators.coffee +++ b/lib/operators/general-operators.coffee @@ -100,7 +100,7 @@ class Delete extends Operator else cursor.moveLeft() if cursor.isAtEndOfLine() - @vimState.activateCommandMode() + @vimState.activateNormalMode() # # It toggles the case of everything selected by the following motion @@ -138,7 +138,7 @@ class ToggleCase extends Operator cursor.moveRight() unless point.column >= lineLength - 1 - @vimState.activateCommandMode() + @vimState.activateNormalMode() # # It copies everything selected by the following motion. @@ -167,7 +167,7 @@ class Yank extends Operator @setTextRegister(@register, text) @editor.setSelectedBufferRanges(newPositions.map (p) -> new Range(p, p)) - @vimState.activateCommandMode() + @vimState.activateNormalMode() # # It combines the current line with the following line. @@ -184,7 +184,7 @@ class Join extends Operator @editor.transact => _.times count, => @editor.joinLines() - @vimState.activateCommandMode() + @vimState.activateNormalMode() # # Repeat the last operation @@ -213,7 +213,7 @@ class Mark extends OperatorWithInput # Returns nothing. execute: () -> @vimState.setMark(@input.characters, @editor.getCursorBufferPosition()) - @vimState.activateCommandMode() + @vimState.activateNormalMode() module.exports = { Operator, OperatorWithInput, OperatorError, Delete, ToggleCase, diff --git a/lib/operators/indent-operators.coffee b/lib/operators/indent-operators.coffee index a00df2dd..618ec0d2 100644 --- a/lib/operators/indent-operators.coffee +++ b/lib/operators/indent-operators.coffee @@ -32,7 +32,7 @@ class Indent extends Operator if mode != 'visual' @editor.setCursorScreenPosition([start.row, 0]) @editor.moveToFirstCharacterOfLine() - @vimState.activateCommandMode() + @vimState.activateNormalMode() # # It outdents everything selected by the following motion. diff --git a/lib/operators/put-operator.coffee b/lib/operators/put-operator.coffee index 615b33ac..3e038a02 100644 --- a/lib/operators/put-operator.coffee +++ b/lib/operators/put-operator.coffee @@ -56,7 +56,7 @@ class Put extends Operator @editor.setCursorScreenPosition(originalPosition) @editor.moveToFirstCharacterOfLine() - @vimState.activateCommandMode() + @vimState.activateNormalMode() if type != 'linewise' @editor.moveLeft() diff --git a/lib/operators/replace-operator.coffee b/lib/operators/replace-operator.coffee index 539ce069..c7595284 100644 --- a/lib/operators/replace-operator.coffee +++ b/lib/operators/replace-operator.coffee @@ -38,4 +38,4 @@ class Replace extends OperatorWithInput @editor.moveDown() @editor.moveToFirstCharacterOfLine() - @vimState.activateCommandMode() + @vimState.activateNormalMode() diff --git a/lib/status-bar-manager.coffee b/lib/status-bar-manager.coffee index cad4158c..0aa8920b 100644 --- a/lib/status-bar-manager.coffee +++ b/lib/status-bar-manager.coffee @@ -2,7 +2,7 @@ ContentsByMode = insert: ["status-bar-vim-mode-insert", "Insert"] - command: ["status-bar-vim-mode-command", "Command"] + normal: ["status-bar-vim-mode-normal", "Normal"] visual: ["status-bar-vim-mode-visual", "Visual"] module.exports = diff --git a/lib/view-models/view-model.coffee b/lib/view-models/view-model.coffee index c0a2e4da..d3c9af44 100644 --- a/lib/view-models/view-model.coffee +++ b/lib/view-models/view-model.coffee @@ -1,13 +1,13 @@ -VimCommandModeInputView = require './vim-command-mode-input-view' +VimNormalModeInputView = require './vim-normal-mode-input-view' # Public: Base class for all view models; a view model -# is the model attached to a VimCommandModeInputView +# is the model attached to a VimNormalModeInputView # which is used when a given operator, motion # needs extra keystroke. # # Ivars: # -# @value - automatically set to the value of typed into the `VimCommandModeInputView` +# @value - automatically set to the value of typed into the `VimNormalModeInputView` # when the `confirm` method is called # class ViewModel @@ -15,7 +15,7 @@ class ViewModel # # operator - An operator, motion, prefix, etc with `@editor` and `@state` set # - # opts - the options to be passed to `VimCommandModeInputView`. Possible options are: + # opts - the options to be passed to `VimNormalModeInputView`. Possible options are: # # - class {String} - the class of the view to be added to the bottom of the screen # @@ -26,15 +26,15 @@ class ViewModel constructor: (@operation, opts={}) -> {@editor, @vimState} = @operation - @view = new VimCommandModeInputView(@, opts) - @editor.commandModeInputView = @view + @view = new VimNormalModeInputView(@, opts) + @editor.normalModeInputView = @view @vimState.onDidFailToCompose => @view.remove() # Public: Overriding this isn't usually necessary in subclasses, this pushes another operation # to the `opStack` in `vim-stack.coffee` which causes the opStack to collapse and # call execute/select on the parent operation # - # view - the `VimCommandModeInputView` that called this method + # view - the `VimNormalModeInputView` that called this method # # Returns nothing. confirm: (view) -> @@ -44,7 +44,7 @@ class ViewModel # to the `opStack` in `vim-stack.coffee` which causes the opStack to collapse and # call execute/select on the parent operation # - # view - the `VimCommandModeInputView` that called this method + # view - the `VimNormalModeInputView` that called this method # # Returns nothing. cancel: (view) -> diff --git a/lib/view-models/vim-command-mode-input-view.coffee b/lib/view-models/vim-normal-mode-input-view.coffee similarity index 94% rename from lib/view-models/vim-command-mode-input-view.coffee rename to lib/view-models/vim-normal-mode-input-view.coffee index f4e966e5..10a33a2f 100644 --- a/lib/view-models/vim-command-mode-input-view.coffee +++ b/lib/view-models/vim-normal-mode-input-view.coffee @@ -1,9 +1,9 @@ {View, TextEditorView} = require 'atom' module.exports = -class VimCommandModeInputView extends View +class VimNormalModeInputView extends View @content: -> - @div class: 'command-mode-input', => + @div class: 'normal-mode-input', => @div class: 'editor-container', outlet: 'editorContainer', => @subview 'editor', new TextEditorView(mini: true) diff --git a/lib/vim-state.coffee b/lib/vim-state.coffee index 66462daf..e08dbd25 100644 --- a/lib/vim-state.coffee +++ b/lib/vim-state.coffee @@ -28,34 +28,34 @@ class VimState @editor.onDidChangeSelectionRange => if _.all(@editor.getSelections(), (selection) -> selection.isEmpty()) - @activateCommandMode() if @mode is 'visual' + @activateNormalMode() if @mode is 'visual' else - @activateVisualMode('characterwise') if @mode is 'command' + @activateVisualMode('characterwise') if @mode is 'normal' @editorElement.classList.add("vim-mode") - @setupCommandMode() + @setupNormalMode() if atom.config.get 'vim-mode.startInInsertMode' @activateInsertMode() else - @activateCommandMode() + @activateNormalMode() destroy: -> @subscriptions.dispose() @deactivateInsertMode() @editorElement.component.setInputEnabled(true) @editorElement.classList.remove("vim-mode") - @editorElement.classList.remove("command-mode") + @editorElement.classList.remove("normal-mode") # Private: Creates the plugin's bindings # # Returns nothing. - setupCommandMode: -> + setupNormalMode: -> @registerCommands - 'activate-command-mode': => @activateCommandMode() + 'activate-normal-mode': => @activateNormalMode() 'activate-linewise-visual-mode': => @activateVisualMode('linewise') 'activate-characterwise-visual-mode': => @activateVisualMode('characterwise') 'activate-blockwise-visual-mode': => @activateVisualMode('blockwise') - 'reset-command-mode': => @resetCommandMode() + 'reset-normal-mode': => @resetNormalMode() 'repeat-prefix': (e) => @repeatPrefix(e) 'reverse-selections': (e) => @reverseSelections(e) 'undo': (e) => @undo(e) @@ -195,7 +195,7 @@ class VimState # with the operation we're going to push onto the stack if (topOp = @topOperation())? and topOp.canComposeWith? and not topOp.canComposeWith(operation) @emitter.emit('failed-to-compose') - @resetCommandMode() + @resetNormalMode() break @opStack.push(operation) @@ -218,7 +218,7 @@ class VimState undo: -> @editor.undo() - @activateCommandMode() + @activateNormalMode() # Private: Processes the command if the last operation is complete. # @@ -228,7 +228,7 @@ class VimState return unless @topOperation().isComplete() - if @mode is 'command' and @topOperation() instanceof Operators.Operator + if @mode is 'normal' and @topOperation() instanceof Operators.Operator @activateOperatorPendingMode() return @@ -239,7 +239,7 @@ class VimState @processOpStack() catch e if (e instanceof Operators.OperatorError) or (e instanceof Motions.MotionError) - @resetCommandMode() + @resetNormalMode() else throw e else @@ -333,17 +333,17 @@ class VimState # Mode Switching ############################################################################## - # Private: Used to enable command mode. + # Private: Used to enable normal mode. # # Returns nothing. - activateCommandMode: -> + activateNormalMode: -> @deactivateInsertMode() @deactivateVisualMode() - @mode = 'command' + @mode = 'normal' @submode = null - @changeModeClass('command-mode') + @changeModeClass('normal-mode') @clearOpStack() selection.clear() for selection in @editor.getSelections() @@ -417,19 +417,19 @@ class VimState @updateStatusBar() changeModeClass: (targetMode) -> - for mode in ['command-mode', 'insert-mode', 'visual-mode', 'operator-pending-mode'] + for mode in ['normal-mode', 'insert-mode', 'visual-mode', 'operator-pending-mode'] if mode is targetMode @editorElement.classList.add(mode) else @editorElement.classList.remove(mode) - # Private: Resets the command mode back to it's initial state. + # Private: Resets the normal mode back to it's initial state. # # Returns nothing. - resetCommandMode: -> + resetNormalMode: -> @clearOpStack() @editor.clearSelections() - @activateCommandMode() + @activateNormalMode() # Private: A generic way to create a Register prefix based on the event. # diff --git a/spec/motions-spec.coffee b/spec/motions-spec.coffee index e765dead..caeaad2d 100644 --- a/spec/motions-spec.coffee +++ b/spec/motions-spec.coffee @@ -11,15 +11,15 @@ describe "Motions", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement helpers.keydown(key, options) - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) + normalModeInputKeydown = (key, opts = {}) -> + opts.element = editor.normalModeInputView.editor.find('input').get(0) opts.raw = true keydown(key, opts) @@ -839,7 +839,7 @@ describe "Motions", -> editor.setCursorScreenPosition([0, 2]) describe "as a motion", -> - describe "in command mode", -> + describe "in normal mode", -> beforeEach -> keydown('g') keydown('g') @@ -874,7 +874,7 @@ describe "Motions", -> expect(editor.getCursorScreenPosition()).toEqual [0, 1] describe "as a repeated motion", -> - describe "in command mode", -> + describe "in normal mode", -> beforeEach -> keydown('2') keydown('g') @@ -956,8 +956,8 @@ describe "Motions", -> it "moves the cursor to the specified search pattern", -> keydown('/') - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'def' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] expect(pane.activate).toHaveBeenCalled() @@ -965,16 +965,16 @@ describe "Motions", -> it "loops back around", -> editor.setCursorBufferPosition([3, 0]) keydown('/') - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'def' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] it "uses a valid regex as a regex", -> keydown('/') # Cycle through the 'abc' on the first line with a character pattern - editor.commandModeInputView.editor.setText '[abc]' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText '[abc]' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [0, 1] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [0, 2] @@ -983,8 +983,8 @@ describe "Motions", -> # Go straight to the literal [abc editor.setText("abc\n[abc]\n") keydown('/') - editor.commandModeInputView.editor.setText '[abc' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText '[abc' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [1, 0] @@ -993,8 +993,8 @@ describe "Motions", -> editor.setText('one two three') keydown('v') keydown('/') - editor.commandModeInputView.editor.setText 'th' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'th' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [0, 9] keydown('d') expect(editor.getText()).toBe 'hree' @@ -1003,8 +1003,8 @@ describe "Motions", -> editor.setText('line1\nline2\nline3') keydown('v') keydown('/') - editor.commandModeInputView.editor.setText 'line' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'line' + editor.normalModeInputView.editor.trigger 'core:confirm' {start, end} = editor.getSelectedBufferRange() expect(start.row).toEqual 0 expect(end.row).toEqual 1 @@ -1020,38 +1020,38 @@ describe "Motions", -> keydown('/') it "works in case sensitive mode", -> - editor.commandModeInputView.editor.setText 'ABC' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'ABC' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [2, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [2, 0] it "works in case insensitive mode", -> - editor.commandModeInputView.editor.setText '\\cAbC' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText '\\cAbC' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [2, 0] it "works in case insensitive mode wherever \\c is", -> - editor.commandModeInputView.editor.setText 'AbC\\c' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'AbC\\c' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [2, 0] it "uses case insensitive search if useSmartcaseForSearch is true and searching lowercase", -> atom.config.set 'vim-mode.useSmartcaseForSearch', true - editor.commandModeInputView.editor.setText 'abc' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'abc' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [1, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [2, 0] it "uses case sensitive search if useSmartcaseForSearch is true and searching uppercase", -> atom.config.set 'vim-mode.useSmartcaseForSearch', true - editor.commandModeInputView.editor.setText 'ABC' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'ABC' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getCursorBufferPosition()).toEqual [2, 0] keydown('n') expect(editor.getCursorBufferPosition()).toEqual [2, 0] @@ -1063,8 +1063,8 @@ describe "Motions", -> beforeEach -> keydown('/') - editor.commandModeInputView.editor.setText 'def' - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.setText 'def' + editor.normalModeInputView.editor.trigger 'core:confirm' describe "the n keybinding", -> it "repeats the last search", -> @@ -1083,15 +1083,15 @@ describe "Motions", -> it "composes with operators", -> keydown('d') keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('def') + editor.normalModeInputView.editor.trigger('core:confirm') expect(editor.getText()).toEqual "def\nabc\ndef\n" it "repeats correctly with operators", -> keydown('d') keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('def') + editor.normalModeInputView.editor.trigger('core:confirm') keydown('.') expect(editor.getText()).toEqual "def\n" @@ -1099,15 +1099,15 @@ describe "Motions", -> describe "when reversed as ?", -> it "moves the cursor backwards to the specified search pattern", -> keydown('?') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('def') + editor.normalModeInputView.editor.trigger('core:confirm') expect(editor.getCursorBufferPosition()).toEqual [3, 0] describe "repeating", -> beforeEach -> keydown('?') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('def') + editor.normalModeInputView.editor.trigger('core:confirm') describe 'the n keybinding', -> it "repeats the last search backwards", -> @@ -1124,34 +1124,34 @@ describe "Motions", -> describe "using search history", -> beforeEach -> keydown('/') - editor.commandModeInputView.editor.setText('def') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('def') + editor.normalModeInputView.editor.trigger('core:confirm') expect(editor.getCursorBufferPosition()).toEqual [1, 0] keydown('/') - editor.commandModeInputView.editor.setText('abc') - editor.commandModeInputView.editor.trigger('core:confirm') + editor.normalModeInputView.editor.setText('abc') + editor.normalModeInputView.editor.trigger('core:confirm') expect(editor.getCursorBufferPosition()).toEqual [2, 0] it "allows searching history in the search field", -> keydown('/') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') + editor.normalModeInputView.editor.trigger('core:move-up') + expect(editor.normalModeInputView.editor.getText()).toEqual('abc') + editor.normalModeInputView.editor.trigger('core:move-up') + expect(editor.normalModeInputView.editor.getText()).toEqual('def') + editor.normalModeInputView.editor.trigger('core:move-up') + expect(editor.normalModeInputView.editor.getText()).toEqual('def') it "resets the search field to empty when scrolling back", -> keydown('/') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-up') - expect(editor.commandModeInputView.editor.getText()).toEqual('def') - editor.commandModeInputView.editor.trigger('core:move-down') - expect(editor.commandModeInputView.editor.getText()).toEqual('abc') - editor.commandModeInputView.editor.trigger('core:move-down') - expect(editor.commandModeInputView.editor.getText()).toEqual '' + editor.normalModeInputView.editor.trigger('core:move-up') + expect(editor.normalModeInputView.editor.getText()).toEqual('abc') + editor.normalModeInputView.editor.trigger('core:move-up') + expect(editor.normalModeInputView.editor.getText()).toEqual('def') + editor.normalModeInputView.editor.trigger('core:move-down') + expect(editor.normalModeInputView.editor.getText()).toEqual('abc') + editor.normalModeInputView.editor.trigger('core:move-down') + expect(editor.normalModeInputView.editor.getText()).toEqual '' describe "the * keybinding", -> beforeEach -> @@ -1319,58 +1319,58 @@ describe "Motions", -> it 'moves to the beginning of the line of a mark', -> editor.setCursorBufferPosition([1,1]) keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') editor.setCursorBufferPosition([0,0]) keydown('\'') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorBufferPosition()).toEqual [1,4] it 'moves literally to a mark', -> editor.setCursorBufferPosition([1,1]) keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') editor.setCursorBufferPosition([0,0]) keydown('`') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorBufferPosition()).toEqual [1,1] it 'deletes to a mark by line', -> editor.setCursorBufferPosition([1,5]) keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') editor.setCursorBufferPosition([0,0]) keydown('d') keydown('\'') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getText()).toEqual '56\n' it 'deletes before to a mark literally', -> editor.setCursorBufferPosition([1,5]) keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') editor.setCursorBufferPosition([0,1]) keydown('d') keydown('`') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getText()).toEqual ' 4\n56\n' it 'deletes after to a mark literally', -> editor.setCursorBufferPosition([1,5]) keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') editor.setCursorBufferPosition([2,1]) keydown('d') keydown('`') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getText()).toEqual ' 12\n 36\n' it 'moves back to previous', -> editor.setCursorBufferPosition([1,5]) keydown('`') - commandModeInputKeydown('`') + normalModeInputKeydown('`') editor.setCursorBufferPosition([2,1]) keydown('`') - commandModeInputKeydown('`') + normalModeInputKeydown('`') expect(editor.getCursorBufferPosition()).toEqual [1,5] describe 'the f/F keybindings', -> @@ -1380,38 +1380,38 @@ describe "Motions", -> it 'moves to the first specified character it finds', -> keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 2] it 'moves backwards to the first specified character it finds', -> editor.setCursorScreenPosition([0, 2]) keydown('F', shift: true) - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it 'respects count forward', -> keydown('2') keydown('f') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 6] it 'respects count backward', -> editor.setCursorScreenPosition([0, 6]) keydown('2') keydown('F', shift: true) - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it "doesn't move if the character specified isn't found", -> keydown('f') - commandModeInputKeydown('d') + normalModeInputKeydown('d') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it "doesn't move if there aren't the specified count of the specified character", -> keydown('1') keydown('0') keydown('f') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it "composes with d", -> @@ -1419,7 +1419,7 @@ describe "Motions", -> keydown('d') keydown('2') keydown('f') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getText()).toEqual 'abcbc\n' describe 'the t/T keybindings', -> @@ -1429,38 +1429,38 @@ describe "Motions", -> it 'moves to the character previous to the first specified character it finds', -> keydown('t') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 2] it 'moves backwards to the character after the first specified character it finds', -> editor.setCursorScreenPosition([0, 2]) keydown('T', shift: true) - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 1] it 'respects count forward', -> keydown('2') keydown('t') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 5] it 'respects count backward', -> editor.setCursorScreenPosition([0, 6]) keydown('2') keydown('T', shift: true) - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 1] it "doesn't move if the character specified isn't found", -> keydown('t') - commandModeInputKeydown('d') + normalModeInputKeydown('d') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it "doesn't move if there aren't the specified count of the specified character", -> keydown('1') keydown('0') keydown('t') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(editor.getCursorScreenPosition()).toEqual [0, 0] it "composes with d", -> @@ -1468,7 +1468,7 @@ describe "Motions", -> keydown('d') keydown('2') keydown('t') - commandModeInputKeydown('b') + normalModeInputKeydown('b') expect(editor.getText()).toBe 'abcbcabc\n' describe 'the V keybinding', -> @@ -1494,7 +1494,7 @@ describe "Motions", -> it "repeat f in same direction", -> keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 2] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1504,7 +1504,7 @@ describe "Motions", -> it "repeat F in same direction", -> editor.setCursorScreenPosition([0,10]) keydown('F', shift: true) - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 8] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1514,7 +1514,7 @@ describe "Motions", -> it "repeat f in opposite direction", -> editor.setCursorScreenPosition([0,6]) keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 8] keydown(',') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1524,7 +1524,7 @@ describe "Motions", -> it "repeat F in opposite direction", -> editor.setCursorScreenPosition([0,4]) keydown('F', shift: true) - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 2] keydown(',') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1533,7 +1533,7 @@ describe "Motions", -> it "alternate repeat f in same direction and reverse", -> keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 2] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1543,7 +1543,7 @@ describe "Motions", -> it "alternate repeat F in same direction and reverse", -> editor.setCursorScreenPosition([0,10]) keydown('F', shift: true) - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 8] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 5] @@ -1552,7 +1552,7 @@ describe "Motions", -> it "repeat t in same direction (won't move)", -> keydown('t') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 1] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 1] @@ -1560,7 +1560,7 @@ describe "Motions", -> it "repeat T in same direction (won't move)", -> editor.setCursorScreenPosition([0,10]) keydown('T', shift: true) - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 9] keydown(';') expect(editor.getCursorScreenPosition()).toEqual [0, 9] @@ -1568,7 +1568,7 @@ describe "Motions", -> it "repeat t in opposite direction first, and then reverse", -> editor.setCursorScreenPosition([0,3]) keydown('t') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 4] keydown(',') expect(editor.getCursorScreenPosition()).toEqual [0, 3] @@ -1578,7 +1578,7 @@ describe "Motions", -> it "repeat T in opposite direction first, and then reverse", -> editor.setCursorScreenPosition([0,4]) keydown('T', shift: true) - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 3] keydown(',') expect(editor.getCursorScreenPosition()).toEqual [0, 4] @@ -1588,7 +1588,7 @@ describe "Motions", -> it "repeat with count in same direction", -> editor.setCursorScreenPosition([0,0]) keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 2] keydown('2') keydown(';') @@ -1597,7 +1597,7 @@ describe "Motions", -> it "repeat with count in reverse direction", -> editor.setCursorScreenPosition([0,6]) keydown('f') - commandModeInputKeydown('c') + normalModeInputKeydown('c') expect(editor.getCursorScreenPosition()).toEqual [0, 8] keydown('2') keydown(',') diff --git a/spec/operators-spec.coffee b/spec/operators-spec.coffee index c974fea0..f565bccd 100644 --- a/spec/operators-spec.coffee +++ b/spec/operators-spec.coffee @@ -11,15 +11,15 @@ describe "Operators", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement helpers.keydown(key, options) - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) + normalModeInputKeydown = (key, opts = {}) -> + opts.element = editor.normalModeInputView.editor.find('input').get(0) opts.raw = true keydown(key, opts) @@ -29,13 +29,13 @@ describe "Operators", -> # doing this without a pending operation throws an exception expect(-> vimState.pushOperations(new Input(''))).toThrow() - # make sure commandModeInputView is created + # make sure normalModeInputView is created keydown('/') expect(vimState.isOperatorPending()).toBe true - editor.commandModeInputView.viewModel.cancel() + editor.normalModeInputView.viewModel.cancel() expect(vimState.isOperatorPending()).toBe false - expect(-> editor.commandModeInputView.viewModel.cancel()).not.toThrow() + expect(-> editor.normalModeInputView.viewModel.cancel()).not.toThrow() describe "the x keybinding", -> describe "on a line with content", -> @@ -190,7 +190,7 @@ describe "Operators", -> it "enters operator-pending mode", -> keydown('d') expect(editorElement.classList.contains('operator-pending-mode')).toBe(true) - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) describe "when followed by a d", -> it "deletes the current line and exits operator-pending mode", -> @@ -204,7 +204,7 @@ describe "Operators", -> expect(editor.getCursorScreenPosition()).toEqual [1, 0] expect(vimState.getRegister('"').text).toBe "abcde\n" expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "deletes the last line", -> editor.setText("12345\nabcde\nABCDE") @@ -245,7 +245,7 @@ describe "Operators", -> expect(editor.getCursorScreenPosition()).toEqual [0, 5] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "deletes to the beginning of the next word", -> editor.setText('abcd efg') @@ -281,7 +281,7 @@ describe "Operators", -> expect(editor.getCursorScreenPosition()).toEqual [0, 6] expect(vimState.getRegister('"').text).toBe "abcde" expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "when followed by an j", -> beforeEach -> @@ -414,7 +414,7 @@ describe "Operators", -> expect(editor.getText()).toBe "12345\n\nABCDE" expect(editor.getCursorScreenPosition()).toEqual [1, 0] - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) expect(editorElement.classList.contains('insert-mode')).toBe(true) describe "when the cursor is on the last line", -> @@ -426,7 +426,7 @@ describe "Operators", -> expect(editor.getText()).toBe "12345\nabcde\n\n" expect(editor.getCursorScreenPosition()).toEqual [2, 0] - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) expect(editorElement.classList.contains('insert-mode')).toBe(true) describe "when the cursor is on the only line", -> @@ -439,7 +439,7 @@ describe "Operators", -> expect(editor.getText()).toBe "\n" expect(editor.getCursorScreenPosition()).toEqual [0, 0] - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) expect(editorElement.classList.contains('insert-mode')).toBe(true) describe "when followed by i w", -> @@ -456,7 +456,7 @@ describe "Operators", -> # Just cannot get "typing" to work correctly in test. editor.setText("12345\nfg\nABCDE") keydown('escape') - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) expect(editor.getText()).toBe "12345\nfg\nABCDE" keydown('u') @@ -527,7 +527,7 @@ describe "Operators", -> it "deletes the contents until the end of the line and enters insert mode", -> expect(editor.getText()).toBe "0\n" expect(editor.getCursorScreenPosition()).toEqual [0, 1] - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) expect(editorElement.classList.contains('insert-mode')).toBe(true) describe "the y keybinding", -> @@ -1067,7 +1067,7 @@ describe "Operators", -> it "allows repeating the operation", -> keydown("escape") keydown(".") - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) expect(editor.getText()).toBe " 12345\nabcde\nABCDE" describe "the < keybinding", -> @@ -1182,31 +1182,31 @@ describe "Operators", -> it "replaces a single character", -> keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getText()).toBe 'x2\nx4\n\n' it "replaces a single character with a line break", -> keydown('r') - editor.commandModeInputView.editor.trigger 'core:confirm' + editor.normalModeInputView.editor.trigger 'core:confirm' expect(editor.getText()).toBe '\n2\n\n4\n\n' expect(editor.getCursorBufferPositions()).toEqual [[1, 0], [3, 0]] it "composes properly with motions", -> keydown('2') keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getText()).toBe 'xx\nxx\n\n' it "does nothing on an empty line", -> editor.setCursorBufferPosition([2, 0]) keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getText()).toBe '12\n34\n\n' it "does nothing if asked to replace more characters than there are on a line", -> keydown('3') keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getText()).toBe '12\n34\n\n' describe "when in visual mode", -> @@ -1216,12 +1216,12 @@ describe "Operators", -> it "replaces the entire selection with the given character", -> keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getText()).toBe 'xx\nxx\n\n' it "leaves the cursor at the beginning of the selection", -> keydown('r') - commandModeInputKeydown('x') + normalModeInputKeydown('x') expect(editor.getCursorBufferPositions()).toEqual [[0, 0], [1, 0]] describe 'the m keybinding', -> @@ -1231,7 +1231,7 @@ describe "Operators", -> it 'marks a position', -> keydown('m') - commandModeInputKeydown('a') + normalModeInputKeydown('a') expect(vimState.getMark('a')).toEqual [0,1] describe 'the ~ keybinding', -> diff --git a/spec/panes-spec.coffee b/spec/panes-spec.coffee index 780cecd0..d8106419 100644 --- a/spec/panes-spec.coffee +++ b/spec/panes-spec.coffee @@ -11,8 +11,8 @@ describe "Panes", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement diff --git a/spec/prefixes-spec.coffee b/spec/prefixes-spec.coffee index c0df5523..0b07ab34 100644 --- a/spec/prefixes-spec.coffee +++ b/spec/prefixes-spec.coffee @@ -11,8 +11,8 @@ describe "Prefixes", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement diff --git a/spec/scroll-spec.coffee b/spec/scroll-spec.coffee index 52cc70c7..7f72365a 100644 --- a/spec/scroll-spec.coffee +++ b/spec/scroll-spec.coffee @@ -11,8 +11,8 @@ describe "Scrolling", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement diff --git a/spec/text-objects-spec.coffee b/spec/text-objects-spec.coffee index 540d0932..4610f52a 100644 --- a/spec/text-objects-spec.coffee +++ b/spec/text-objects-spec.coffee @@ -11,15 +11,15 @@ describe "TextObjects", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement helpers.keydown(key, options) - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) + normalModeInputKeydown = (key, opts = {}) -> + opts.element = editor.normalModeInputView.editor.find('input').get(0) opts.raw = true keydown(key, opts) @@ -37,7 +37,7 @@ describe "TextObjects", -> expect(editor.getCursorScreenPosition()).toEqual [0, 6] expect(vimState.getRegister('"').text).toBe "abcde" expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "selects inside the current word in visual mode", -> keydown('v') @@ -68,7 +68,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "()" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the current word in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -78,7 +78,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "( something in here and in () )" expect(editor.getCursorScreenPosition()).toEqual [0, 28] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "works with multiple cursors", -> editor.setText("( a b ) cde ( f g h ) ijk") @@ -106,7 +106,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "{}" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the current word in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -116,7 +116,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "{ something in here and in {} }" expect(editor.getCursorScreenPosition()).toEqual [0, 28] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'i<' text object", -> beforeEach -> @@ -130,7 +130,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "<>" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the current word in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -140,7 +140,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "< something in here and in <> >" expect(editor.getCursorScreenPosition()).toEqual [0, 28] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'i[' text object", -> beforeEach -> @@ -154,7 +154,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "[]" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the current word in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -164,7 +164,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "[ something in here and in [] ]" expect(editor.getCursorScreenPosition()).toEqual [0, 28] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'i\'' text object", -> beforeEach -> @@ -178,7 +178,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "''here' ' and over here" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the next string in operator-pending mode (if not in a string)", -> editor.setCursorScreenPosition([0, 29]) @@ -188,7 +188,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "' something in here and in 'here'' and over here" expect(editor.getCursorScreenPosition()).toEqual [0, 33] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "makes no change if past the last string on a line", -> editor.setCursorScreenPosition([0, 39]) @@ -198,7 +198,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "' something in here and in 'here' ' and over here" expect(editor.getCursorScreenPosition()).toEqual [0, 39] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'i\"' text object", -> beforeEach -> @@ -212,7 +212,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "\"\"here\" \" and over here" expect(editor.getCursorScreenPosition()).toEqual [0, 1] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators inside the next string in operator-pending mode (if not in a string)", -> editor.setCursorScreenPosition([0, 29]) @@ -222,7 +222,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "\" something in here and in \"here\"\" and over here" expect(editor.getCursorScreenPosition()).toEqual [0, 33] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "makes no change if past the last string on a line", -> editor.setCursorScreenPosition([0, 39]) @@ -247,7 +247,7 @@ describe "TextObjects", -> expect(editor.getCursorScreenPosition()).toEqual [0, 6] expect(vimState.getRegister('"').text).toBe "abcde " expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "selects from the start of the current word to the start of the next word in visual mode", -> keydown('v') @@ -278,7 +278,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "" expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current parentheses in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -288,7 +288,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "( something in here and in )" expect(editor.getCursorScreenPosition()).toEqual [0, 27] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'a{' text object", -> beforeEach -> @@ -302,7 +302,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "" expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current curly brackets in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -312,7 +312,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "{ something in here and in }" expect(editor.getCursorScreenPosition()).toEqual [0, 27] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'a<' text object", -> beforeEach -> @@ -326,7 +326,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "" expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current angle brackets in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -336,7 +336,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "< something in here and in >" expect(editor.getCursorScreenPosition()).toEqual [0, 27] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'a[' text object", -> beforeEach -> @@ -350,7 +350,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "" expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current square brackets in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -360,7 +360,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "[ something in here and in ]" expect(editor.getCursorScreenPosition()).toEqual [0, 27] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'a\'' text object", -> beforeEach -> @@ -374,7 +374,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "here' '" expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current single quotes in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -384,7 +384,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe "' something in here and in 'here" expect(editor.getCursorScreenPosition()).toEqual [0, 31] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) describe "the 'a\"' text object", -> beforeEach -> @@ -398,7 +398,7 @@ describe "TextObjects", -> expect(editor.getText()).toBe 'here" "' expect(editor.getCursorScreenPosition()).toEqual [0, 0] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "applies operators around the current double quotes in operator-pending mode (second test)", -> editor.setCursorScreenPosition([0, 29]) @@ -408,4 +408,4 @@ describe "TextObjects", -> expect(editor.getText()).toBe "\" something in here and in \"here" expect(editor.getCursorScreenPosition()).toEqual [0, 31] expect(editorElement.classList.contains('operator-pending-mode')).toBe(false) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) diff --git a/spec/vim-mode-spec.coffee b/spec/vim-mode-spec.coffee index e8dc2d98..4b4a51cb 100644 --- a/spec/vim-mode-spec.coffee +++ b/spec/vim-mode-spec.coffee @@ -17,9 +17,9 @@ describe "VimMode", -> editorElement = atom.views.getView(editor) describe ".activate", -> - it "puts the editor in command-mode initially by default", -> + it "puts the editor in normal-mode initially by default", -> expect(editorElement.classList.contains('vim-mode')).toBe(true) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "doesn't register duplicate command listeners for editors", -> editor.setText("12345") @@ -37,7 +37,7 @@ describe "VimMode", -> it "removes the vim classes from the editor", -> atom.packages.deactivatePackage('vim-mode') expect(editorElement.classList.contains("vim-mode")).toBe(false) - expect(editorElement.classList.contains("command-mode")).toBe(false) + expect(editorElement.classList.contains("normal-mode")).toBe(false) it "removes the vim commands from the editor element", -> vimCommands = -> diff --git a/spec/vim-state-spec.coffee b/spec/vim-state-spec.coffee index 0ede42d4..35ca3256 100644 --- a/spec/vim-state-spec.coffee +++ b/spec/vim-state-spec.coffee @@ -13,22 +13,22 @@ describe "VimState", -> editorElement = element editor = editorElement.getModel() vimState = editorElement.vimState - vimState.activateCommandMode() - vimState.resetCommandMode() + vimState.activateNormalMode() + vimState.resetNormalMode() keydown = (key, options={}) -> options.element ?= editorElement helpers.keydown(key, options) - commandModeInputKeydown = (key, opts = {}) -> - opts.element = editor.commandModeInputView.editor.find('input').get(0) + normalModeInputKeydown = (key, opts = {}) -> + opts.element = editor.normalModeInputView.editor.find('input').get(0) opts.raw = true keydown(key, opts) describe "initialization", -> - it "puts the editor in command-mode initially by default", -> + it "puts the editor in normal-mode initially by default", -> expect(editorElement.classList.contains('vim-mode')).toBe(true) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) it "puts the editor in insert-mode if startInInsertMode is true", -> atom.config.set 'vim-mode.startInInsertMode', true @@ -42,11 +42,11 @@ describe "VimState", -> expect(editorElement.component.isInputEnabled()).toBeTruthy() it "removes the mode classes from the editor", -> - expect(editorElement.classList.contains("command-mode")).toBeTruthy() + expect(editorElement.classList.contains("normal-mode")).toBeTruthy() vimState.destroy() - expect(editorElement.classList.contains("command-mode")).toBeFalsy() + expect(editorElement.classList.contains("normal-mode")).toBeFalsy() - describe "command-mode", -> + describe "normal-mode", -> describe "when entering an insertable character", -> beforeEach -> keydown('\\') @@ -88,7 +88,7 @@ describe "VimState", -> it "puts the editor into visual characterwise mode", -> expect(editorElement.classList.contains('visual-mode')).toBe(true) expect(vimState.submode).toEqual 'characterwise' - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) describe "the V keybinding", -> beforeEach -> @@ -99,7 +99,7 @@ describe "VimState", -> it "puts the editor into visual linewise mode", -> expect(editorElement.classList.contains('visual-mode')).toBe(true) expect(vimState.submode).toEqual 'linewise' - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) it "selects the current line", -> expect(editor.getLastSelection().getText()).toEqual '012345\n' @@ -110,12 +110,12 @@ describe "VimState", -> it "puts the editor into visual characterwise mode", -> expect(editorElement.classList.contains('visual-mode')).toBe(true) expect(vimState.submode).toEqual 'blockwise' - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) describe "selecting text", -> it "puts the editor into visual mode", -> editor.setText("abc def") - expect(vimState.mode).toEqual 'command' + expect(vimState.mode).toEqual 'normal' editor.setSelectedBufferRanges([[[0, 0], [0, 3]]]) expect(vimState.mode).toEqual 'visual' expect(vimState.submode).toEqual 'characterwise' @@ -126,7 +126,7 @@ describe "VimState", -> it "puts the editor into insert mode", -> expect(editorElement.classList.contains('insert-mode')).toBe(true) - expect(editorElement.classList.contains('command-mode')).toBe(false) + expect(editorElement.classList.contains('normal-mode')).toBe(false) describe "with content", -> beforeEach -> editor.setText("012345\n\nabcdef") @@ -150,9 +150,9 @@ describe "VimState", -> it 'properly clears the opStack', -> keydown('d') keydown('r') - expect(vimState.mode).toBe 'command' + expect(vimState.mode).toBe 'normal' expect(vimState.opStack.length).toBe 0 - commandModeInputKeydown('escape') + normalModeInputKeydown('escape') keydown('d') expect(editor.getText()).toBe '012345\nabcdef' @@ -183,19 +183,19 @@ describe "VimState", -> it "allows the cursor to be placed on the \n character", -> expect(editor.getCursorScreenPosition()).toEqual [0, 6] - it "puts the editor into command mode when is pressed", -> + it "puts the editor into normal mode when is pressed", -> keydown('escape') - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) expect(editorElement.classList.contains('insert-mode')).toBe(false) expect(editorElement.classList.contains('visual-mode')).toBe(false) - it "puts the editor into command mode when is pressed", -> + it "puts the editor into normal mode when is pressed", -> helpers.mockPlatform(editorElement, 'platform-darwin') keydown('c', ctrl: true) helpers.unmockPlatform(editorElement) - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) expect(editorElement.classList.contains('insert-mode')).toBe(false) expect(editorElement.classList.contains('visual-mode')).toBe(false) @@ -209,11 +209,11 @@ describe "VimState", -> expect(editor.getSelectedBufferRanges()).toEqual [[[0, 4], [0, 5]]] expect(editor.getSelectedText()).toBe("t") - it "puts the editor into command mode when is pressed", -> + it "puts the editor into normal mode when is pressed", -> keydown('escape') expect(editor.getCursorBufferPositions()).toEqual [[0, 4]] - expect(editorElement.classList.contains('command-mode')).toBe(true) + expect(editorElement.classList.contains('normal-mode')).toBe(true) expect(editorElement.classList.contains('visual-mode')).toBe(false) describe "motions", -> @@ -242,7 +242,7 @@ describe "VimState", -> it "operate on the current selection", -> expect(editor.getText()).toEqual "\nabcdef" - describe "returning to command-mode", -> + describe "returning to normal-mode", -> beforeEach -> editor.setText("012345\n\nabcdef") editor.selectLinesContainingCursors() @@ -284,32 +284,32 @@ describe "VimState", -> it "basic marking functionality", -> editor.setCursorScreenPosition([1, 1]) keydown('m') - commandModeInputKeydown('t') + normalModeInputKeydown('t') expect(editor.getText()).toEqual "text in line 1\ntext in line 2\ntext in line 3" editor.setCursorScreenPosition([2, 2]) keydown('`') - commandModeInputKeydown('t') + normalModeInputKeydown('t') expect(editor.getCursorScreenPosition()).toEqual [1,1] it "real (tracking) marking functionality", -> editor.setCursorScreenPosition([2, 2]) keydown('m') - commandModeInputKeydown('q') + normalModeInputKeydown('q') editor.setCursorScreenPosition([1, 2]) keydown('o') keydown('escape') keydown('`') - commandModeInputKeydown('q') + normalModeInputKeydown('q') expect(editor.getCursorScreenPosition()).toEqual [3,2] it "real (tracking) marking functionality", -> editor.setCursorScreenPosition([2, 2]) keydown('m') - commandModeInputKeydown('q') + normalModeInputKeydown('q') editor.setCursorScreenPosition([1, 2]) keydown('d') keydown('d') keydown('escape') keydown('`') - commandModeInputKeydown('q') + normalModeInputKeydown('q') expect(editor.getCursorScreenPosition()).toEqual [1,2] diff --git a/styles/vim-mode.less b/styles/vim-mode.less index a4589375..9cbd130a 100644 --- a/styles/vim-mode.less +++ b/styles/vim-mode.less @@ -1,7 +1,7 @@ @import "syntax-variables"; @import "ui-variables"; -.command-mode-input atom-text-editor[mini] { +.normal-mode-input atom-text-editor[mini] { background-color: inherit; border: none; width: 100%; @@ -20,7 +20,7 @@ opacity: 0.5; } -atom-text-editor.vim-mode.command-mode, +atom-text-editor.vim-mode.normal-mode, atom-text-editor.vim-mode.operator-pending-mode, atom-text-editor.vim-mode.visual-mode, { @@ -33,7 +33,7 @@ atom-text-editor.vim-mode.visual-mode, } } -atom-text-editor.vim-mode.command-mode.is-focused, +atom-text-editor.vim-mode.normal-mode.is-focused, atom-text-editor.vim-mode.operator-pending-mode.is-focused, atom-text-editor.vim-mode.visual-mode.is-focused {