     else
       beforeText[0]
 
+  nextCharacterIsWordCharacter: ->
+    /[A-Za-z0-9_]/.test @nextCharacter()
+
   # Run a movement.  For convenience, the following three argument forms are available:
   #   @runMovement "forward word"
   #   @runMovement [ "forward", "word" ]
   #   @runMovement "forward", "word"
+  #
+  # The granularities are word, "line", "lineboundary", "sentence" and "paragraph".  In addition, we implement
+  # the pseudo granularity "vimword", which implements vim-like word movement, for "w".
+  #
   runMovement: (args...) ->
     # Normalize the various argument forms (to an array of two strings: direction and granularity).
     movement =

        document.activeElement.blur()

    super event, target
    if @yankedText? and not @options.noCopyToClipboard
      console.log "yank:", @yankedText if @debug
      @copy @yankedText, true

  handleMovementKeyChar: (args...) ->
    super args...
    @yank() if @options.oneMovementOnly

  selectLine: (count, collapse) ->
    @runMovement backward, "lineboundary"
    @collapseSelectionToFocus() if collapse
    @runMovement forward, "line" for [0...count]

  # This installs a basic binding for find mode, "n" and "N".
  # FIXME(smblott).  This is a mess, it needs to be reworked.  Ideally, incorporate FindMode.
  installFindMode: ->
    previousFindRange = null

    executeFind = (findBackwards) =>
      query = getFindModeQuery()
      if query
        caseSensitive = Utils.hasUpperCase query
        @protectClipboard =>
          initialRange = @selection.getRangeAt(0).cloneRange()
          direction = @getDirection()

          # Re-select the previous match, if any; this tells Chrome where to start.
          @selectRange previousFindRange if previousFindRange

          window.find query, caseSensitive, findBackwards, true, false, true, false
          previousFindRange = newFindRange = @selection.getRangeAt(0).cloneRange()
          # FIXME(smblott).  What if there are no matches?

          # Install a new range from the original selection anchor to the end of the new match.
          range = document.createRange()
          which = if direction == forward then "start" else "end"
          range.setStart initialRange["#{which}Container"], initialRange["#{which}Offset"]
          range.setEnd newFindRange.endContainer, newFindRange.endOffset
          @selectRange range

          # If we're now going backwards (or if the selection is empty), then extend the selection to include
          # the match itself.
          if @getDirection() == backward or @selection.toString().length == 0
            range.setStart newFindRange.startContainer, newFindRange.startOffset
            @selectRange range

    @movements.n = (count) -> executeFind false
    @movements.N = (count) -> executeFind true

class VisualLineMode extends VisualMode
  constructor: (options = {}) ->

      exitOnEscape: true
    super extend defaults, options

    switch @selection.type
      when "None"
        @establishInitialSelectionAnchor()
        if @selection.type == "None"
          HUD.showForDuration "Create a selection before entering visual mode.", 2500
          @exit()
          return
      when "Range"
        @collapseSelectionToFocus()

