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

84 active golfers, 236 entries

Leaderboard (lowest score wins):
20
#31 - Benjamin Kiesl / @BenjaminKiesl

10/15/2018 at 04:08PM

20
#32 - Mihai / @mihaicristiant

12/04/2018 at 07:36AM

20
#33 - churaki / @churaki

01/30/2019 at 07:55AM

20
#34 - Lory / @Lory46845742

11/19/2019 at 12:25PM

21
#35 - Valacar / @valacar

08/16/2018 at 07:20AM

21
#36 - Артем Мухометзянов / @Timon_Surikat

08/18/2018 at 11:13PM

21
#37 - Daniel Vaqueiro / @chimidea

09/01/2018 at 12:51AM

21
#38 - Daniel Steinberg / @dstein64

02/14/2019 at 06:07AM

21
#39 - Ariel Miculas / @ArielMiculas

09/24/2019 at 03:29PM

22
#40 - Weston Neal / @wtneal

09/04/2018 at 10:11PM

22
#41 - prince ducaca / @prince_du_caca

09/27/2018 at 10:58PM

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

08/11/2018 at 12:24PM

23
#43 - 徐学健 / @zebrallel

08/15/2018 at 10:21AM

23
#44 - daniel / @daniel31464605

08/22/2018 at 06:04AM

23
#45 - Fabio Branquinho / @branquif

11/08/2018 at 09:24PM

23
#46 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 05:37AM

24
#47 - Kritixi Lithos / @kritixilithos

08/11/2018 at 11:54AM

24
#48 - h43z / @h43z

08/11/2018 at 11:16PM

24
#49 - Marco Magdy / @marcomacdee

08/13/2018 at 07:57PM

24
#50 - 安藤 / @andou2106

09/03/2018 at 03:47PM

24
#51 - a / @a05150445

09/06/2018 at 04:13AM

24
#52 - pankaj singh / @pankajsingh013

01/17/2019 at 04:40PM

24
#53 - Ivo Blöchliger / @aigledesalpes

08/07/2019 at 06:57PM

25
#54 - SumOfAllN00bs / @SumOfAllN00bs

08/22/2018 at 04:40AM

25
#55 - Oren Koriat / @KoriatOren

12/23/2018 at 10:46AM

25
#56 - Simon Wilkinson / @simondwilkinson

08/24/2019 at 03:04PM

25
#57 - José / @AngelGaldamez

10/06/2019 at 02:26AM

26
#58 - yqu212 / @yqu212

08/11/2018 at 02:23AM

26
#59 - Kristijan Husak / @kristijan_husak

08/11/2018 at 05:43PM

26
#60 - Dr. Rev. J. "Paranoid Android" Kirchartz / @JKirchartz

08/19/2018 at 05:11AM