 # Word motions
 # ------------
 
-# these return a new regex each time so that we always get a fresh lastIndex
-# a string of non-whitespace characters
+# Return a new regex with a fresh lastIndex each time for use in word motions.
+# There are two different kinds of words:
+#
+# * A **WORD** is a string of non-whitespace characters.
+# * A **word** is a string of regex word characters (i.e. `[A-Za-z0-9_]`) *or* a
+#   string of non-whitespace non-word characters (i.e. special chars)
 WORDRegex = -> /\S+/g 
-# a string of word characters (i.e. [A-Za-z0-9_]) OR a string of non-whitespace non-word characters (i.e. special chars)
 wordRegex = -> /(\w+)|([^\w\s]+)/g
 
 
-# move to the end of the current word or the end of the next word if on the end of a
-# word
+# Move to the next end of a **word**.
 map 'e', class MoveToWordEnd extends Motion
   exec: repeatCountTimes (jim) ->
     regex = if @bigWord then WORDRegex() else wordRegex()


{Command, repeatCountTimes} = require './helpers'

# accumulate the default mappings
defaultMappings = {}
map = (keys, motionClass) -> defaultMappings[keys] = motionClass

# base class for all motions
class Motion extends Command

  # motions do the same thing in visual mode
  visualExec: (jim) -> @exec jim


# Define an unmapped `Motion` that will be used for double operators (e.g. `cc`,
# `2yy`, `3d4d`).
class LinewiseCommandMotion extends Motion
  linewise: yes
  exec: (jim) ->
    if additionalLines = @count - 1
      new MoveDown(additionalLines).exec jim


# Basic directional motions
# -------------------------
