Sunday, January 26, 2014

Re: Replacing a string which is in a line and not in the beginning?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQIcBAEBAgAGBQJS5MDsAAoJEHWv8EScabi80t0P/0BpCV4ba6Feroz7wRTRmpEx
US8vDysoEqKU6L6OC4xXxFC/v5LvhHG3xyMCrff9zVWvP6+ZMtiKju80TfQXHa3O
pJIMDH3hOySego89I7CmSp94OVPV4EHn8ZLYg8DC5ZajSDbksKwYyYrMPgufAMXy
kCo0lUizA+Z91rRkKWvqZF6nQngGQlfEkbRe/T83qHsN2o1cW6fzkV7IVxrPUDpl
E+AieAbxT4YKkRmCHlQrOimNeM3BiMYIKl3T31JUOhM672GBOHTyxwImCAqvINSR
e7ACjFEDxBfG3TIzvBCejLEW3Bj8TnKQ1aVeCKTyH1xIfg1q7YW1AaelPIkIfLre
rGPF9pwvy3xNsjRN010BmHK4mnqI+5b/vDp4G8qIv00L7ZW98lpNo0w00/FEYmn1
El8NDe5SZywOYTkmrCtpe3YlK9z6Wl9cy+wumfSGMTQOoKGj8kenjBAsV+Hp9Gz2
HrqPTFHThHNSAaFdnOUASyZAIthgkmtjg9GO/4oAhgJCyqhQbuUPusAB7U4c/ScA
H4Ad5WYs3DODmFFjuUwPpTY67udvfGH0Xu+JyXa271lXD7XpmKdqveOfYbElPSbC
2rGGCSJrCUbkCyKDpUVifrmfd31i144rkO6AcxrsYfvyBlAOly51x3Vf/yxH/2AJ
F5ykO9wFNKBgDNM/j8fO
=g6Az
-----END PGP SIGNATURE-----
On 25 Jan 2014, at 22:17, ZyX wrote:

>> I'm fairly new to Vim myself, but I just tried this.
>>
>> I entered this into a new buffer --
>>
>> - This is a te- st
>> - foo bar
>> - This is another - test I mean
>>
>> and ran this from the command line (using "x" as the replacement text) --
>>
>> :%s/\v^(.+)\- /\1x/g
>>
>> and I got this:
>>
>> - This is a texst
>> - foo bar
>> - This is another xtest I mean
>>
>> Note that I used "\v" (very magic) to make Vim use regular expressions that
>> the rest of the world understands. :-)
>
> Not as easy. According to the documentation only alphanumeric characters, underscore and non-ASCII are guaranteed not to have special meaning in this mode. I.e. you must escape the space just as you escaped hyphenminus. Both though *currently* have no special meaning.

Good to know about \v. That would have solved it really fast ^^

Niels

No comments:

Post a Comment