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 @bszonye:

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

30 active golfers, 68 entries

Solutions by @bszonye:
17
#7 - Bradd Szonye / @bszonye

07/14/2013 at 09:16AM

21
#>15 - Bradd Szonye / @bszonye

07/14/2013 at 09:00AM

26
#>27 - Bradd Szonye / @bszonye

07/14/2013 at 08:55AM