1

For example, I would like to substitute character [ with < for the line below:

inoremap []     []<Left>

my proposed method from command mode in vim is:

s/[/\%x3c/g

where \%x3c is < in ASCII hex but it didn't work.

1 Answers1

2

Use the following:

s/\[/\</g

Just escape the characters:

  • [ must be escaped to: \[ (or [[])
  • < may be escaped to: \<

Anyway, your problem doesn't seem to be in the < but in the [.

pah
  • 4,700
  • 6
  • 28
  • 37
  • Thanks for the answer. Vim seems strange to me on when to escape and when not. Wonder if there's a list of characters that need to be escape? Didn't seem to happen to such characters like { } ( ) ... –  Jul 20 '16 at 08:13
  • `<` doesn't need to be escaped, only `[`. – romainl Jul 20 '16 at 08:13
  • @root See http://stackoverflow.com/questions/399078/what-special-characters-must-be-escaped-in-regular-expressions – pah Jul 20 '16 at 08:29