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

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

31 active golfers, 70 entries

Solutions by @justinjaffray:
23
#22 - Justin / @justinjaffray

05/04/2013 at 07:13PM

23
#>22 - Justin / @justinjaffray

05/04/2013 at 07:26PM

23
#>22 - Justin / @justinjaffray

05/04/2013 at 07:36PM

23
#>22 - Justin / @justinjaffray

05/04/2013 at 07:39PM

24
#>24 - Justin / @justinjaffray

05/04/2013 at 07:33PM

26
#>25 - Justin / @justinjaffray

05/04/2013 at 07:12PM

27
#>29 - Justin / @justinjaffray

05/04/2013 at 07:24PM

28
#>31 - Justin / @justinjaffray

05/04/2013 at 07:24PM