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 100 remaining solutions by signing in and submitting your own entry
#101 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

101 active golfers, 297 entries

Leaderboard (lowest score wins):
19
#1 - Kerson Hsiao / @KersonHsiao

08/12/2018 at 03:27AM

19
#2 - Pratik / @prathik_t

08/12/2018 at 11:36AM

19
#3 - John Braxler / @braxler

08/13/2018 at 11:55AM

19
#4 - "Smylers" / @Smylers2

08/13/2018 at 02:00PM

19
#5 - Keldwik Chaldain / @Suskeyhose

08/14/2018 at 08:43PM

19
#6 - fucus / @fishlovebanana

08/19/2018 at 07:27AM

19
#7 - Epecb / @BceEpecb

09/05/2018 at 12:41AM

19
#8 - Jeff / @sir_wiggles3

09/07/2018 at 09:50AM

19
#9 - Rich Cheng / @sedm0784

09/10/2018 at 03:29PM

19
#10 - royer / @RoyerMoyer1

09/15/2018 at 12:03AM

19
#11 - Turkey Man / @lvturkeyman

09/21/2018 at 03:45AM

19
#12 - Rasmus Bergström / @JRasmusBm

09/27/2018 at 08:54AM

19
#13 - Dax / @zacoxi

11/01/2018 at 03:12AM

19
#14 - name / @name65894813

11/16/2018 at 07:59PM

19
#15 - T A / @SirAviles

02/13/2019 at 12:14AM

19
#16 - alekfed / @alek_fed

04/15/2019 at 02:20PM

19
#17 - Grant / @grant_7788

05/13/2019 at 08:21AM

19
#18 - Дима / @dimkino

05/31/2019 at 10:33AM

19
#19 - majo senf / @majo_senf

06/18/2019 at 02:09PM

19
#20 - vimgolfer / @vimgolfer7

10/23/2019 at 01:24AM

19
#21 - Miłosz Łakomy / @foobar01123

11/26/2019 at 12:15PM

19
#22 - Jung Yeon Park / @park_jungy

02/12/2021 at 10:56PM

19
#23 - hepebexè / @hepebexe

02/27/2021 at 07:10PM

19
#24 - Alex / @AlexanderHeatl2

07/06/2022 at 11:54PM

19
#25 - Janzen / @__Coos

10/03/2022 at 01:11PM

19
#26 - Peppa Pig / @PeppaPigSg

07/19/2024 at 12:31AM

19
#27 - nickGPT / @nickandbro

08/27/2024 at 05:12AM

20
#28 - Jon Krause / @jkrause314

08/11/2018 at 12:59AM

20
#29 - Javier Blanco / @jbgutierrez

08/11/2018 at 09:08AM

20
#30 - PCS Solutions / @PeteSolutions

08/11/2018 at 11:11AM