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 5b6e21c9a893790006232531

Swap the operands under comparison

Swap the operands under comparison to prevent null pointer exception (at least in java)

Start file
if(lang.equals("en_US")) {
       
System.out.println("The lang is en_US i.e english US"+
}

if(lang.equals("es_US")) {
       
System.out.println("The lang is es_US i.e spanish US"+
}

if(lang.equals("fr_US")) {
       
System.out.println("The lang is fr_US i.e france US"+
}
End file
if("en_US".equals(lang)) {
       
System.out.println("The lang is en_US i.e english US"+
}

if("es_US".equals(lang)) {
       
System.out.println("The lang is es_US i.e spanish US"+
}

if("fr_US".equals(lang)) {
       
System.out.println("The lang is fr_US i.e france US"+
}

View Diff

1c1
< if(lang.equals("en_US")) {
---
> if("en_US".equals(lang)) {
5c5
< if(lang.equals("es_US")) {
---
> if("es_US".equals(lang)) {
9c9
< if(lang.equals("fr_US")) {
---
> if("fr_US".equals(lang)) {

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 102 remaining solutions by signing in and submitting your own entry
#103 Jurica / @Jurica34581259 - Score: 63 - 11/16/18 @ 11:19
:%s/lang\.equals(\(.*\)")/\1"/<CR>:%s/US")/US".equals(lang))/<CR>:wq<CR>

0 comments


Created by: @saurabh908583

103 active golfers, 304 entries

Leaderboard (lowest score wins):
30
#91 - lzh / @ly_zhng

06/14/2020 at 05:37PM

32
#92 - Shunichi Kanade / @shunkana

11/23/2018 at 09:13AM

35
#93 - PJ Frazer / @pj_frazer

12/02/2018 at 02:32AM

36
#94 - Adam / @askoufish

11/25/2018 at 11:25PM

37
#95 - Miki Tebeka / @tebeka

08/12/2018 at 05:13AM

39
#96 - saurabh tripathi / @saurabh908583

08/10/2018 at 11:39PM

39
#97 - Vanda Hendrychová / @vandiacutek

08/23/2018 at 07:45PM

39
#98 - Pumpkin Parapet / @PumpkinParapet

10/06/2018 at 01:39AM

45
#99 - Bennett / @bennettbackward

12/19/2018 at 12:30PM

46
#100 - Chirag Joshi / @thechijos

08/14/2018 at 05:18AM

54
#101 - urandom / @ttyrandom

10/20/2018 at 06:14PM

55
#102 - testingvimgolf / @testingvimgolf

08/12/2018 at 03:23AM

63
#103 - Jurica / @Jurica34581259

11/16/2018 at 11:19AM