ajaxorg/ace · error · Error

Search feature not available. Requires searchcursor.js or an

Error message

Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.

What it means

The :substitute ex command requires a search cursor implementation (cm.getSearchCursor), normally provided by searchcursor.js. Without it, Ace-vim cannot perform the search/replace and throws instead of silently failing.

Source

Thrown at src/keyboard/vim.js:6580

            var lineHandle = matchedLines[index++];
            var lineNum = cm.getLineNumber(lineHandle);
            if (lineNum == null) {
              nextCommand();
              return;
            }
            var command = (lineNum + 1) + cmd;
            exCommandDispatcher.processCommand(cm, command, {
              callback: nextCommand
            });
          } else if (cm.releaseLineHandles) {
            cm.releaseLineHandles();
          }
        };
        nextCommand();
      },
      substitute: function(cm, params) {
        if (!cm.getSearchCursor) {
          throw new Error('Search feature not available. Requires searchcursor.js or ' +
              'any other getSearchCursor implementation.');
        }
        var argString = params.argString;
        var tokens = argString ? splitBySeparator(argString, argString[0]) : [];
        var regexPart, replacePart = '', trailing, flagsPart, count;
        var confirm = false; // Whether to confirm each replace.
        var global = false; // True to replace all instances on a line, false to replace only 1.
        if (tokens.length) {
          regexPart = tokens[0];
          if (getOption('pcre') && regexPart !== '') {
              regexPart = new RegExp(regexPart).source; //normalize not escaped characters
          }
          replacePart = tokens[1];
          if (replacePart !== undefined) {
            if (getOption('pcre')) {
              replacePart = unescapeRegexReplace(replacePart.replace(/([^\\])&/g,"$1$$&"));
            } else {
              replacePart = translateRegexReplace(replacePart);

View on GitHub (pinned to 2c1eddc392)

Solutions

  1. Load the search cursor extension (e.g. include and require 'ace/ext/searchbox' / search support) before using :substitute
  2. Use a full Ace build that includes search dependencies
  3. Fall back to editor.replaceAll(regex, options) API instead of the vim :s command

Example fix

// before
// only vim mode loaded, no search support
:substitute /foo/bar/g
// after
ace.require('ace/ext/searchbox'); // ensure search cursor available
// then :%s/foo/bar/g works
Defensive patterns

Strategy: validation

Validate before calling

if (typeof editor.getSearchCursor !== 'function') {
  ace.require('ace/ext/searchbox'); // or load a build with search support
}
// then run :%s/foo/bar/g

Type guard

function hasSearchSupport(cm) { return typeof cm.getSearchCursor === 'function'; }

Try / catch

try { executeEx(':%s/foo/bar/g'); } catch (e) { if (/Search feature not available/.test(e.message)) { editor.replaceAll('bar', { needle: 'foo' }); } else throw e; }

Prevention

When it happens

Trigger: Using :s/foo/bar/g in Ace's vim mode without loading ace/ext/searchbox or otherwise having getSearchCursor available on the editor instance; bundling vim.js without its search dependency.

Common situations: Custom minimal Ace builds excluding the search extension; lazy-loading vim mode without search support; direct ace.require('ace/keyboard/vim') usage in a stripped bundle.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of ajaxorg/ace@2c1eddc392 (2026-08-30). Data as JSON: /api/errors/79061837cf601ae0. Report an issue: GitHub.