     super
     @reversed()
 
+# keymap: n
+class RepeatSearch extends SearchBase
+  @extend()
+  complete: true
+  saveCurrentSearch: false
+
+  constructor: ->
+    super
+    @input = @vimState.getSearchHistoryItem(0) ? ''
+    @replicateCurrentSearch()
+
+  reversed: ->
+    @reverse = not @initiallyReversed
+    this
+
+# keymap: N
+class RepeatSearchBackwards extends RepeatSearch
+  @extend()
+  constructor: ->
+    super
+    @reversed()
+
+# keymap: %
 OpenBrackets = ['(', '{', '[']
 CloseBrackets = [')', '}', ']']
 AnyBracket = new RegExp(OpenBrackets.concat(CloseBrackets).map(_.escapeRegExp).join("|"))
 
-# keymap: n
-class RepeatSearch extends SearchBase
-  @extend()
-  complete: true
-  dontUpdateCurrentSearch: true
-
-  constructor: ->
-    super
-    @input = @vimState.getSearchHistoryItem(0) ? ''
-    @replicateCurrentSearch()
-
-  reversed: ->
-    @reverse = not @initiallyReversed
-    this
-
-# keymap: N
-class RepeatSearchBackwards extends RepeatSearch
-  @extend()
-  constructor: ->
-    super
-    @reversed()
-
-# keymap: %
 class BracketMatchingMotion extends SearchBase
   @extend()
   inclusive: true

# -------------------------
class SearchBase extends Motion
  @extend()
  dontUpdateCurrentSearch: false
  complete: false

  constructor: ->
    super
    @reverse = @initiallyReversed = false
    @updateCurrentSearch() unless @dontUpdateCurrentSearch

  reversed: =>
    @initiallyReversed = @reverse = true

    # FIXME: This must depend on the current language
    defaultIsKeyword = "[@a-zA-Z0-9_\-]+"
    userIsKeyword = atom.config.get('vim-mode.iskeyword')
    @wordRegex = new RegExp(userIsKeyword or defaultIsKeyword)
    @abort() unless word = @getCurrentWord()
    @input = if /\W/.test(word) then "#{word}\\b" else "\\b#{word}\\b"
    unless @input is @vimState.getSearchHistoryItem()
      @vimState.pushSearchHistory(@input)

  # FIXME: Should not move cursor.
  getCurrentWord: ->
    cursor = @editor.getLastCursor()
    rowStart = cursor.getBufferRow()
    range = cursor.getCurrentWordBufferRange({@wordRegex})
    if range.end.isEqual(cursor.getBufferPosition())
      point = cursor.getBeginningOfNextWordBufferPosition({@wordRegex})
      if point.row is rowStart
        cursor.setBufferPosition(point)
        range = cursor.getCurrentWordBufferRange({@wordRegex})

    if range.isEmpty()
      ''
    else
      cursor.setBufferPosition(range.start)
      @editor.getTextInBufferRange(range)

# keymap: #
class ReverseSearchCurrentWord extends SearchCurrentWord
