私は私のftpluginファイルの中に以下の正規表現を持っています。その目的は、Enterキーを押した後に代入演算子をスペースで区切ることです:
inoremap :s/\s*\([=+!-]\?=\)\s*/ \1 /ge:noho
=、==、!=、+ =、 -
=で動作します。これまでのところ、その部分は完璧に動作しているようです。この問題は、この正規表現を次のように変更して比較演算子を区切ったときに発生します。
inoremap :s/\s*\([=+!-]\?=\|[><]=\?\)\s*/ \1 /ge:noho
After this change, neither assignment, nor comparison operators
are matched anymore (no errors, just nothing happens). However,
searching for this new pattern in vim directly highlights all of
them. I'm not sure if the issue is due to < and > being
special characters in .vim files (used for , etc.), I tried
escaping them with \, but that didn't seem to help. Also, when I
put them inside the same block as the rest of the operators, they
work fine:
inoremap :s/\s*\([=+!-><]\?=\)\s*/ \1 /ge:noho
The only problem in this case, however, is that if I type
something like xx = (a+b+c+d+e+f) - (g+h+i)
rather
than x = (a + b + c + d + e + f) - (g + h + i)
).
Likewise, I don't want my negations to look like if( !
(statement) ...
. What am I doing wrong? Also, I'm using vim
7.2.245. Thanks