Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions keymaps/vim-mode.cson
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
10 changes: 5 additions & 5 deletions lib/operators/general-operators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -184,7 +184,7 @@ class Join extends Operator
@editor.transact =>
_.times count, =>
@editor.joinLines()
@vimState.activateCommandMode()
@vimState.activateNormalMode()

#
# Repeat the last operation
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/operators/indent-operators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/operators/put-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Put extends Operator
@editor.setCursorScreenPosition(originalPosition)
@editor.moveToFirstCharacterOfLine()

@vimState.activateCommandMode()
@vimState.activateNormalMode()
if type != 'linewise'
@editor.moveLeft()

Expand Down
2 changes: 1 addition & 1 deletion lib/operators/replace-operator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ class Replace extends OperatorWithInput
@editor.moveDown()
@editor.moveToFirstCharacterOfLine()

@vimState.activateCommandMode()
@vimState.activateNormalMode()
2 changes: 1 addition & 1 deletion lib/status-bar-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
16 changes: 8 additions & 8 deletions lib/view-models/view-model.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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
# Public: Override this in subclasses for custom initialization
#
# 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
#
Expand All @@ -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) ->
Expand All @@ -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) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
40 changes: 20 additions & 20 deletions lib/vim-state.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -218,7 +218,7 @@ class VimState

undo: ->
@editor.undo()
@activateCommandMode()
@activateNormalMode()

# Private: Processes the command if the last operation is complete.
#
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.
#
Expand Down
Loading