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

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

42 active golfers, 133 entries

Solutions by @AlexanderHeatl2:
20
#21 - Alex / @AlexanderHeatl2

07/26/2022 at 10:11PM

21
#>26 - Alex / @AlexanderHeatl2

07/26/2022 at 10:10PM

22
#>30 - Alex / @AlexanderHeatl2

07/26/2022 at 10:10PM

24
#>38 - Alex / @AlexanderHeatl2

07/26/2022 at 10:09PM

30
#>38 - Alex / @AlexanderHeatl2

07/26/2022 at 10:08PM