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):
23
#61 - James / @Dronak

12/07/2022 at 07:16PM

24
#62 - Kritixi Lithos / @kritixilithos

08/11/2018 at 11:54AM

24
#63 - ؜ / @h43z

08/11/2018 at 11:16PM

24
#64 - Marco Magdy / @marcomacdee

08/13/2018 at 07:57PM

24
#65 - 安藤 / @andou2106

09/03/2018 at 03:47PM

24
#66 - a / @a05150445

09/06/2018 at 04:13AM

24
#67 - pankaj singh / @pankajsingh013

01/17/2019 at 04:40PM

24
#68 - Ivo Blöchliger / @aigledesalpes

08/07/2019 at 06:57PM

24
#69 - jonas-grobe / @jonas-grobe

02/03/2024 at 04:04PM

24
#70 - Nalfein (Kenny) / @Nalfein16

05/17/2025 at 06:20AM

25
#71 - SumOfAllN00bs / @SumOfAllN00bs

08/22/2018 at 04:40AM

25
#72 - Oren Koriat / @KoriatOren

12/23/2018 at 10:46AM

25
#73 - Simon Wilkinson / @simondwilkinson

08/24/2019 at 03:04PM

25
#74 - Aioriya / @AioriyaDonk

10/06/2019 at 02:26AM

25
#75 - Adi / @adi2004

10/07/2024 at 10:06AM

26
#76 - yqu212 / @yqu212

08/11/2018 at 02:23AM

26
#77 - Kristijan Husak / @kristijan_husak

08/11/2018 at 05:43PM

26
#78 - Dr Rev J. “I am not a bot!” Kirchartz, KSC, KHS / @JKirchartz

08/19/2018 at 05:11AM

26
#79 - Jules / @namebrandloser

10/26/2018 at 11:32PM

26
#80 - Bruce Adams / @bruceadams1054

11/08/2018 at 08:18AM

26
#81 - Luis Rodriguez / @luisthecoder

11/14/2018 at 02:36AM

26
#82 - Chris Lesage / @chrislesage

06/07/2019 at 04:42AM

27
#83 - Christian Fosli / @porridge111

08/12/2018 at 07:17PM

27
#84 - Alexander Zheleznov / @ephemerr

08/17/2018 at 09:16AM

27
#85 - Sergio / @voyeg3r

08/19/2018 at 04:15PM

27
#86 - Roberto Martínez / @nilp0inter

08/20/2018 at 09:17PM

28
#87 - Vanildo S. Mangueira / @vanildo_souto

08/13/2018 at 01:51PM

28
#88 - Aaron / @_Lordofthevoid_

12/06/2019 at 02:01PM

29
#89 - Sxcy / @SxcyX

10/22/2018 at 01:52PM

29
#90 - Phoon / @justflashhim

05/10/2019 at 09:54PM