 
 {Command, repeatCountTimes} = require './helpers'
 
-# accumulate the default mappings
+
+# The default key mappings are specified alongside the definitions of each
+# motion.  Accumulate the mappings so they can be exported.
 defaultMappings = {}
 map = (keys, motionClass) -> defaultMappings[keys] = motionClass
+
 
 # base class for all motions
 class Motion extends Command

          column = firstMatchOnSubsequentLine[0].length + firstMatchOnSubsequentLine.index - 1
          break
        else if row is jim.adaptor.lastRow()
          # there are no more non-blank characters, don't move the cursor
          return

    jim.adaptor.moveTo row, column

map 'E', class MoveToBigWordEnd extends MoveToWordEnd
  bigWord: yes


# move to the beginning of the next word
map 'w', class MoveToNextWord extends Motion
  exclusive: yes
  exec: (jim) ->

      rightOfCursor = line.substring column

      thisMatch = regex.exec rightOfCursor

      # If the next match isn't on this line, find it on the next.
      if not thisMatch or not nextMatch = regex.exec rightOfCursor

        # If the user typed `dw` on the last word of a line, for instance, just
        # delete the rest of the word instead of deleting to the start of the
        # word on the next line.
        if timesLeft is 0 and @operation
          column = line.length

        else
          line = jim.adaptor.lineText ++row
          nextLineMatch = regex.exec line
          column = nextLineMatch?.index or 0

      # `cw` actually behaves like `ce` instead of `dwi`. So if this motion is
      # part of a `Change` operation, ensure that the last time the loop is
      # executed we execute a `MoveToWordEnd` instead.
      else if timesLeft is 0 and @operation?.switchToMode is 'insert'
        lastMotion = new MoveToWordEnd()
        lastMotion.bigWord = @bigWord
        lastMotion.exec jim
        @exclusive = no
        return

      # If we've found the beginning of the next match and it's not already
      # under the cursor, go to it.
      else if thisMatch?.index > 0
        column += thisMatch.index

      # If we're on top of part of a word, go to the next one.
      else
        column += nextMatch.index

      # Move to the `row` and `column` that have been determined.
      jim.adaptor.moveTo row, column

map 'W', class MoveToNextBigWord extends MoveToNextWord
