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

Right Align Part of the line

The challenge is to right align a part of the line - this is useful in some SQL queries where it's more clear which are the fields displayed

Start file
SELECT 
col1 AS column1,
cast(column2 AS varchar(255)) AS column2,
cast(evenlongercolumn3 AS varchar(255)) AS column3,
cast(yetevenlongercolumn4 AS varchar(255)) AS column4,
cast(thelongestcolumnyouhaveeverseen9 AS varchar(255)) AS column5,
col1 AS column6,
cast(column7 AS varchar(255)) AS column7,
cast(evenlongercolumn8 AS varchar(255)) AS column8,
cast(yetevenlongercolumn9 AS varchar(255)) AS column9,
cast(thelongestcolumnyouhaveeverseen10 AS varchar(255)) AS column10
FROM table;
End file
SELECT 
col1                                                    AS column1,
cast(column2 AS varchar(255))                           AS column2,
cast(evenlongercolumn3 AS varchar(255))                 AS column3,
cast(yetevenlongercolumn4 AS varchar(255))              AS column4,
cast(thelongestcolumnyouhaveeverseen9 AS varchar(255))  AS column5,
col1                                                    AS column6,
cast(column7 AS varchar(255))                           AS column7,
cast(evenlongercolumn8 AS varchar(255))                 AS column8,
cast(yetevenlongercolumn9 AS varchar(255))              AS column9,
cast(thelongestcolumnyouhaveeverseen10 AS varchar(255)) AS column10
FROM table;

View Diff

2,10c2,10
< col1 AS column1,
< cast(column2 AS varchar(255)) AS column2,
< cast(evenlongercolumn3 AS varchar(255)) AS column3,
< cast(yetevenlongercolumn4 AS varchar(255)) AS column4,
< cast(thelongestcolumnyouhaveeverseen9 AS varchar(255)) AS column5,
< col1 AS column6,
< cast(column7 AS varchar(255)) AS column7,
< cast(evenlongercolumn8 AS varchar(255)) AS column8,
< cast(yetevenlongercolumn9 AS varchar(255)) AS column9,
---
> col1                                                    AS column1,
> cast(column2 AS varchar(255))                           AS column2,
> cast(evenlongercolumn3 AS varchar(255))                 AS column3,
> cast(yetevenlongercolumn4 AS varchar(255))              AS column4,
> cast(thelongestcolumnyouhaveeverseen9 AS varchar(255))  AS column5,
> col1                                                    AS column6,
> cast(column7 AS varchar(255))                           AS column7,
> cast(evenlongercolumn8 AS varchar(255))                 AS column8,
> cast(yetevenlongercolumn9 AS varchar(255))              AS column9,

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 13 remaining solutions by signing in and submitting your own entry
#14 Norbert / @mullno - Score: 23 - 04/19/20 @ 17:21
qq+$FA60i <Esc>056ldwq9@qZZ

0 comments


#15 Moatvald / @moatvald - Score: 23 - 04/20/20 @ 10:20
qqj$FA60i <Esc>056ldwq9@qZZ

0 comments


#16 temp / @temp16343368 - Score: 23 - 04/20/20 @ 14:28
qqj$BB60i <Esc>056ldwq9@qZZ

0 comments


#17 José / @AngelGaldamez - Score: 23 - 05/08/20 @ 22:49
qq<CR>$2B60i <Esc>056ldwq9@qZZ

0 comments


#18 Quentin Leroy / @qnleroy - Score: 23 - 05/15/20 @ 05:14
qa+$FA60i <Esc>056ldwq9@aZZ

0 comments


Created by: @tefetic

18 active golfers, 35 entries

Leaderboard (lowest score wins):
19
#1 - John Braxler / @braxler

04/20/2020 at 03:41PM

19
#2 - せいほう / @FICSQF

04/21/2020 at 12:40PM

19
#3 - Arthur Goodman / @ArthurGoodman3

04/30/2020 at 09:45PM

20
#4 - Jon Krause / @jkrause314

04/19/2020 at 05:23PM

20
#5 - Ollin Boer Bohan / @madebyollin

04/19/2020 at 06:03PM

20
#6 - Smylers / @Smylers2

04/19/2020 at 09:06PM

20
#7 - Saki Gw / @Sakigw

04/20/2020 at 06:33AM

20
#8 - Roger Stoltz / @rogsto1

04/21/2020 at 09:40AM

20
#9 - garry quested / @GQuested

04/22/2020 at 01:19PM

20
#10 - Seve / @__Seve__

04/22/2020 at 02:35PM

20
#11 - floyd / @floyd10086

05/18/2020 at 09:49AM

22
#12 - volandkit / @volandkit

04/20/2020 at 06:07PM

22
#13 - pady. / @hundertzwoelf_

05/20/2020 at 04:36PM

23
#14 - Norbert / @mullno

04/19/2020 at 05:21PM

23
#15 - Moatvald / @moatvald

04/20/2020 at 10:20AM

23
#16 - temp / @temp16343368

04/20/2020 at 02:28PM

23
#17 - José / @AngelGaldamez

05/08/2020 at 10:49PM

23
#18 - Quentin Leroy / @qnleroy

05/15/2020 at 05:14AM