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

Comparing Schema With Diff

Sometimes databases output things differently one to another. Fixing things that are out of order will make the diffs more usable.

Start file
CREATE TABLE sales.stores (					CREATE TABLE sales.stores (
 store_id INT IDENTITY (1, 1) PRIMARY KEY,			 store_id INT IDENTITY (1, 1) PRIMARY KEY,
 store_name VARCHAR (255) NOT NULL,				 store_name VARCHAR (255) NOT NULL,
 phone VARCHAR (25),						 phone VARCHAR (25),
 email VARCHAR (255),						 email VARCHAR (255),
 street VARCHAR (255),						 street VARCHAR (255),
 city VARCHAR (255),						 city VARCHAR (255),
 state VARCHAR (10),						 state VARCHAR (10),
 zip_code VARCHAR (5)						 zip_code VARCHAR (5)
);								);


							      >	CREATE TABLE sales.customers (
							      >	 customer_id INT IDENTITY (1, 1) PRIMARY KEY,
							      >	 first_name VARCHAR (255) NOT NULL,
							      >	 last_name VARCHAR (255) NOT NULL,
							      >	 phone VARCHAR (25),
							      >	 street VARCHAR (255),
							      >	 city VARCHAR (50),
							      >	 state VARCHAR (25),
							      >	 zip_code VARCHAR (5)
							      >	);
							      >
CREATE TABLE production.categories (				CREATE TABLE production.categories (
 category_id INT IDENTITY (1, 1) PRIMARY KEY,			 category_id INT IDENTITY (1, 1) PRIMARY KEY,
 category_name VARCHAR (255) NOT NULL				 category_name VARCHAR (255) NOT NULL
);								);


CREATE TABLE production.products (				CREATE TABLE production.products (
 product_id INT IDENTITY (1, 1) PRIMARY KEY,			 product_id INT IDENTITY (1, 1) PRIMARY KEY,
 product_name VARCHAR (255) NOT NULL,				 product_name VARCHAR (255) NOT NULL,
 brand_id INT NOT NULL,						 brand_id INT NOT NULL,
 category_id INT NOT NULL,					 category_id INT NOT NULL,
 model_year SMALLINT NOT NULL,					 model_year SMALLINT NOT NULL,
 list_price DECIMAL (10, 2) NOT NULL,				 list_price DECIMAL (10, 2) NOT NULL,
 FOREIGN KEY (category_id) 					 FOREIGN KEY (category_id) 
        REFERENCES production.categories (category_id) 		        REFERENCES production.categories (category_id) 
        ON DELETE CASCADE ON UPDATE CASCADE,			        ON DELETE CASCADE ON UPDATE CASCADE,
 FOREIGN KEY (brand_id) 					 FOREIGN KEY (brand_id) 
        REFERENCES sales.brands (brand_id) 			        REFERENCES sales.brands (brand_id) 
        ON DELETE CASCADE ON UPDATE CASCADE			        ON DELETE CASCADE ON UPDATE CASCADE
);								);


CREATE TABLE sales.customers (				      <
 customer_id INT IDENTITY (1, 1) PRIMARY KEY,		      <
 first_name VARCHAR (255) NOT NULL,			      <
 last_name VARCHAR (255) NOT NULL,			      <
 phone VARCHAR (25),					      <
 email VARCHAR (255) NOT NULL,				      <
 street VARCHAR (255),					      <
 city VARCHAR (50),					      <
 state VARCHAR (25),					      <
 zip_code VARCHAR (5)					      <
);							      <
End file
CREATE TABLE sales.stores (					CREATE TABLE sales.stores (
 store_id INT IDENTITY (1, 1) PRIMARY KEY,			 store_id INT IDENTITY (1, 1) PRIMARY KEY,
 store_name VARCHAR (255) NOT NULL,				 store_name VARCHAR (255) NOT NULL,
 phone VARCHAR (25),						 phone VARCHAR (25),
 email VARCHAR (255),						 email VARCHAR (255),
 street VARCHAR (255),						 street VARCHAR (255),
 city VARCHAR (255),						 city VARCHAR (255),
 state VARCHAR (10),						 state VARCHAR (10),
 zip_code VARCHAR (5)						 zip_code VARCHAR (5)
);								);

							      <
CREATE TABLE production.categories (				CREATE TABLE production.categories (
 category_id INT IDENTITY (1, 1) PRIMARY KEY,			 category_id INT IDENTITY (1, 1) PRIMARY KEY,
 category_name VARCHAR (255) NOT NULL				 category_name VARCHAR (255) NOT NULL
);								);


CREATE TABLE production.products (				CREATE TABLE production.products (
 product_id INT IDENTITY (1, 1) PRIMARY KEY,			 product_id INT IDENTITY (1, 1) PRIMARY KEY,
 product_name VARCHAR (255) NOT NULL,				 product_name VARCHAR (255) NOT NULL,
 brand_id INT NOT NULL,						 brand_id INT NOT NULL,
 category_id INT NOT NULL,					 category_id INT NOT NULL,
 model_year SMALLINT NOT NULL,					 model_year SMALLINT NOT NULL,
 list_price DECIMAL (10, 2) NOT NULL,				 list_price DECIMAL (10, 2) NOT NULL,
 FOREIGN KEY (category_id) 					 FOREIGN KEY (category_id) 
        REFERENCES production.categories (category_id) 		        REFERENCES production.categories (category_id) 
        ON DELETE CASCADE ON UPDATE CASCADE,			        ON DELETE CASCADE ON UPDATE CASCADE,
 FOREIGN KEY (brand_id) 					 FOREIGN KEY (brand_id) 
        REFERENCES sales.brands (brand_id) 			        REFERENCES sales.brands (brand_id) 
        ON DELETE CASCADE ON UPDATE CASCADE			        ON DELETE CASCADE ON UPDATE CASCADE
);								);


CREATE TABLE sales.customers (					CREATE TABLE sales.customers (
 customer_id INT IDENTITY (1, 1) PRIMARY KEY,			 customer_id INT IDENTITY (1, 1) PRIMARY KEY,
 first_name VARCHAR (255) NOT NULL,				 first_name VARCHAR (255) NOT NULL,
 last_name VARCHAR (255) NOT NULL,				 last_name VARCHAR (255) NOT NULL,
 phone VARCHAR (25),						 phone VARCHAR (25),
 email VARCHAR (255) NOT NULL,				      <
 street VARCHAR (255),						 street VARCHAR (255),
 city VARCHAR (50),						 city VARCHAR (50),
 state VARCHAR (25),						 state VARCHAR (25),
 zip_code VARCHAR (5)						 zip_code VARCHAR (5)
);								);

View Diff

12,23c12
< 
< 							      >	CREATE TABLE sales.customers (
< 							      >	 customer_id INT IDENTITY (1, 1) PRIMARY KEY,
< 							      >	 first_name VARCHAR (255) NOT NULL,
< 							      >	 last_name VARCHAR (255) NOT NULL,
< 							      >	 phone VARCHAR (25),
< 							      >	 street VARCHAR (255),
< 							      >	 city VARCHAR (50),
< 							      >	 state VARCHAR (25),
< 							      >	 zip_code VARCHAR (5)
< 							      >	);
< 							      >
---
> 							      <
46,50c35,39
< CREATE TABLE sales.customers (				      <
<  customer_id INT IDENTITY (1, 1) PRIMARY KEY,		      <
<  first_name VARCHAR (255) NOT NULL,			      <
<  last_name VARCHAR (255) NOT NULL,			      <
<  phone VARCHAR (25),					      <
---
> CREATE TABLE sales.customers (					CREATE TABLE sales.customers (
>  customer_id INT IDENTITY (1, 1) PRIMARY KEY,			 customer_id INT IDENTITY (1, 1) PRIMARY KEY,
>  first_name VARCHAR (255) NOT NULL,				 first_name VARCHAR (255) NOT NULL,
>  last_name VARCHAR (255) NOT NULL,				 last_name VARCHAR (255) NOT NULL,
>  phone VARCHAR (25),						 phone VARCHAR (25),
52,56c41,45
<  street VARCHAR (255),					      <
<  city VARCHAR (50),					      <
<  state VARCHAR (25),					      <
<  zip_code VARCHAR (5)					      <
< );							      <
---
>  street VARCHAR (255),						 street VARCHAR (255),
>  city VARCHAR (50),						 city VARCHAR (50),
>  state VARCHAR (25),						 state VARCHAR (25),
>  zip_code VARCHAR (5)						 zip_code VARCHAR (5)
> );								);

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 8 remaining solutions by signing in and submitting your own entry
#9 Daniel Keast / @daniel_keast - Score: 53 - 10/16/19 @ 08:25
17Go<<Esc>5k<C-V>10j$d/<<CR>p:%s/<>//<CR>?<<CR>xvip:retab<CR>?><CR>r<k11dkZZ

0 comments


#10 nickGPT / @nickandbro - Score: 53 - 08/24/24 @ 14:01
17Go<<Esc>5k<C-V>10j$d/<<CR>p:%s/<>//<CR>?<<CR>xvip:retab<CR>?><CR>r<k11dkZZ

0 comments


Created by: @BradleySmall

10 active golfers, 52 entries

Leaderboard (lowest score wins):
30
#1 - Ivan Volosyuk / @IvanVolosyuk

10/26/2019 at 07:33AM

30
#2 - John Braxler / @braxler

10/28/2019 at 02:59PM

30
#3 - Saki Gw / @Sakigw

10/31/2019 at 01:59PM

30
#4 - sapir malka / @sapir5522

12/26/2019 at 12:29PM

30
#5 - Peppa Pig / @PeppaPi95550250

07/02/2024 at 06:46AM

34
#6 - Mario Olofo / @mario_olofo

10/21/2019 at 02:46AM

34
#7 - Filipe Brandenburger / @filbranden

03/30/2020 at 05:24AM

36
#8 - J̻̕ͅo̠̻̘h̼̖n̙̩̝͕ D̹̗̗͝oe̶̱̥͙ / @JohnJDoe2

10/21/2019 at 07:11AM

53
#9 - Daniel Keast / @daniel_keast

10/16/2019 at 08:25AM

53
#10 - nickGPT / @nickandbro

08/24/2024 at 02:01PM