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

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

42 active golfers, 133 entries

Solutions by @Seve_py:
20
#14 - Seve / @Seve_py

04/22/2020 at 02:35PM

22
#>28 - Seve / @Seve_py

04/22/2020 at 02:16PM