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 by @foobar01123:

Unlock 4 remaining solutions by signing in and submitting your own entry
Created by: @tefetic

42 active golfers, 133 entries

Solutions by @foobar01123:
19
#5 - Miłosz Łakomy / @foobar01123

07/20/2021 at 12:20PM

20
#>17 - Miłosz Łakomy / @foobar01123

07/19/2021 at 10:55AM

21
#>26 - Miłosz Łakomy / @foobar01123

07/18/2021 at 11:02AM

22
#>30 - Miłosz Łakomy / @foobar01123

07/16/2021 at 04:45PM