1

In vim, I could use :%sno/[abt]//g to remove all text of "[abt]" literally (as explained here).

I tried the same command in evil-mode, but it complains it doesn't understand the sno command, so how can I do the same thing in evil-mode?

itsjeyd
  • 5,070
  • 2
  • 30
  • 49
Daniel Wu
  • 5,853
  • 12
  • 42
  • 93

2 Answers2

3

To my knowledge, evil does not (yet?) support the "magic/no magic" regexp options (actually, it only does a smallish subset of ex functionality, so I don't think % will work either). As @Ehvince's answer suggests, the standard Emacs way to do the replace is with query-replace or query-replace-regexp. If you'd like to stick to evil, just escape the square brackets with a backslash:

:s/\[abt\]//g

NB: backslash escapes in Emacs often bite people coming from other environments or programming languages; have a look at the bottom of this manual node on the backslash for more information.

Dan
  • 5,209
  • 1
  • 25
  • 37
  • Good to know! `%` is a nice feature; answer corrected to strikethrough the offending passage. – Dan Aug 12 '14 at 17:19
2

You would use the emacs command query-replace bound to M-%:

M-% [abt] RET <nothing> RET

and then approve each occurence with y or all with !.

The doc is at C-h f query-replace.

query-replace-regexp is bound to C-M-%.

Ehvince
  • 17,274
  • 7
  • 58
  • 79