Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 518360f3fa5db2000200001a

Lookahead and Lookbehind

Look everywhere

Start file
Example for reference:

:%s/\(some\)\@<=thing/one/g
searches for all strings starting with some, then matching thing
changes thing into one
end result: something becomes someone

:%s/\(some\)\@<!thing/one/g
searches for all strings not starting with some, then matching thing
changes thing into one
end result: something is not changed, but everything changes to everyone

:%s/some\(thing\)\@=/every/g
searches for all strings ending with thing, then matching some
changes some into every
end result: something becomes everything

:%s/some\(thing\)\@!/every/g
searches for all strings not ending with thing, then matching some
changes some into every
end result: something is not changed, but someone becomes everyone
End file
Example for reference:

:%s/\(some\)\@<=thing/one/g
searches for all strings starting with some, then matching thing
changes thing into one
end result: someone becomes someone

:%s/\(some\)\@<!thing/one/g
searches for all strings not starting with some, then matching thing
changes thing into one
end result: something is not changed, but everyone changes to everyone

:%s/some\(thing\)\@=/every/g
searches for all strings ending with thing, then matching some
changes some into every
end result: everything becomes everything

:%s/some\(thing\)\@!/every/g
searches for all strings not ending with thing, then matching some
changes some into every
end result: something is not changed, but everyone becomes everyone

View Diff

0a1
> 
6c7
< end result: something becomes someone
---
> end result: someone becomes someone
11c12
< end result: something is not changed, but everything changes to everyone
---
> end result: something is not changed, but everyone changes to everyone
16c17
< end result: something becomes everything
---
> end result: everything becomes everything
21c22
< end result: something is not changed, but someone becomes everyone
---
> end result: something is not changed, but everyone becomes everyone

Solutions by @kentyuan:

Unlock 2 remaining solutions by signing in and submitting your own entry
Created by: @zulolosi

31 active golfers, 70 entries

Solutions by @kentyuan:
22
#16 - Kai Yuan / @kentyuan

05/03/2013 at 09:04PM

23
#>21 - Kai Yuan / @kentyuan

05/03/2013 at 08:55PM