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 @madebyollin:

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

42 active golfers, 133 entries

Solutions by @madebyollin:
20
#9 - Ollin Boer Bohan / @madebyollin

04/19/2020 at 06:03PM

22
#>27 - Ollin Boer Bohan / @madebyollin

04/19/2020 at 05:57PM