Note: This website is archived. For up-to-date information about D projects and development, please visit

Token Search and replace

As of version 0.3.22 Visual D features a search and replace dialog that can be used to do replacements based on the tokenizer used by Visual D for syntax highlighting. The dialog can be opened through the Visual D menu:


A token consists of the actual lexical D element and any preceding white spaces including comments. The search and replacement texts are tokenized according to the D language, matching the result against the tokenized source text ignoring syntactically unimportant text like comments and line breaks. Brace matching is supported, allowing to match nested expressions nicely.

Here is an example:


Executing 'Replace All' will exchange the arguments of all calls and declarations of function 'fun' in the current document, even if the arguments span multiple lines and include nested expressions.

The search text allows some special $ tokens:

  • $_numNAME - any integer literal
  • $_identNAME - any identifier (no keywords)
  • $_dotidentNAME - any identifier.identifier pair
  • $_exprNAME - any sequence of brace matched tokens terminated by closing bracket or ";"
  • $_notNAME - any token not matching the following token
  • $_optNAME - the following token or nothing
  • $NAME - any sequence of tokens greedily stopped by the following token
  • token$NAME - any token starting with "token"

NAME can be any alpha numeric identifier.

Special tokens in the replacement string:

Any $-token used in the replacement string is replaced with the identically named capture from the matched search string. $* is relaced by the the whole matched string.