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):
20
#31 - Piotr Walkusz / @piotrwalkusz1

08/11/2018 at 03:36PM

20
#32 - tPenguinLTG / @tpenguinltg

08/12/2018 at 03:52AM

20
#33 - Coruja Queridinha / @miriamretka

08/19/2018 at 08:59PM

20
#34 - Cam Smith / @Comradesmith

08/21/2018 at 10:37AM

20
#35 - Joey / @joeyism101

09/03/2018 at 02:08AM

20
#36 - Roger Bongers / @RogerBongers

10/05/2018 at 07:27PM

20
#37 - Benjamin Kiesl / @BenjaminKiesl

10/15/2018 at 04:08PM

20
#38 - Mihai / @mihaicristiant

12/04/2018 at 07:36AM

20
#39 - churaki / @churaki

01/30/2019 at 07:55AM

20
#40 - Lory / @Lory46845742

11/19/2019 at 12:25PM

20
#41 - Jean George / @JeanGeo20504212

10/07/2021 at 09:28AM

20
#42 - Luoyb / @Luoyb

11/11/2023 at 01:33AM

20
#43 - jimmymills / @jimmymills

05/28/2025 at 09:58PM

21
#44 - Valacar / @valacar

08/16/2018 at 07:20AM

21
#45 - Тёма / @Timon_Surikat

08/18/2018 at 11:13PM

21
#46 - Daniel Vaqueiro / @chimidea

09/01/2018 at 12:51AM

21
#47 - Dan / @dstein64

02/14/2019 at 06:07AM

21
#48 - Ariel Miculas / @ArielMiculas

09/24/2019 at 03:29PM

21
#49 - Ryan Nevius / @ryannevius

03/23/2020 at 08:35PM

22
#50 - Weston Neal / @wtneal

09/04/2018 at 10:11PM

22
#51 - prince ducaca / @prince_du_caca

09/27/2018 at 10:58PM

22
#52 - A A A / @37fatos

03/11/2021 at 11:15PM

23
#53 - 村橋究理基M.Kuriki@北大 / @mkuriki_

08/11/2018 at 12:24PM

23
#54 - 徐学健 / @zebrallel

08/15/2018 at 10:21AM

23
#55 - daniel / @daniel31464605

08/22/2018 at 06:04AM

23
#56 - Fabio Branquinho / @branquif

11/08/2018 at 09:24PM

23
#57 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 05:37AM

23
#58 - RockerZZY / @rocker_zzy

06/14/2020 at 06:10AM

23
#59 - x03n046 / @x03n046

06/14/2022 at 02:45AM

23
#60 - Brandon / @Brandon10678836

08/29/2022 at 12:16PM