December 21, 2016

The Code for Git merge is one of the most sophisticated pieces of software ever written. There is so much stuff that goes inside during a merge that its just mind boggling. Just for that alone, Linus could be considered a programming genius. Too bad for other geniuses, he has Linux kernel on his resume :-D.

As the title suggests this article is about Octopus Merge in Git. For this I hope you know what a basic Git merge is and what it means to merge. If you're completely unfamiliar with Git, then I've no idea what you're doing here. You better read up on some Git 101 before jumping to this article.

Anyway, Just to brush up, this is how a simple/familiar Git merge goes ..

We have a branch called feature that diverged from master at the second commit and went to have two commits of its own.

Note: For the branch pictures in this article I am using a Git GUI tool called Git Kraken. I have been trying it a few days now and it looks quite promising. I am a fan of its clean and minimalist UI and have been using it extensively for the beautiful visualization of branches. And above all, It is free for personal non-commercial use. So, you can try it out for free.

Now you want to add those cool new changes on the feature branch to master. The way you do it is by merging (Let's not talk about Rebasing for now. We will look at it another time). So, when you merge this is how it looks like.

This is all the usual stuff that we are all familiar with.

Now there is another type of merge called the The Octopus Merge. At least some of you must have heard about it either from an online video or from a colleague in your office that seems to know everything. Either way the Octopus merge is a really fun way of Merging. You probably won't get to do this at your work as a lot of companies think this complicates things and we all know how much Companies hate complexity. Anyway, Let's see what it looks like. I have a local git repository with three branches branch1, branch2, branch3 along with master. All four of these branches have two extra commits from the point they diverged.

Now if you want to merge them, the usual way would be to merge two branches at a time to finally get to the final combination after three merges like so.

This may seem fine and might actually be the only way you would think about this if not for the Octopus merge. You have three merge commits here and as we know merge commits are noise. They pollute the history of your repository and interrupt the story told by your Git history. So, how about keeping the noise low by just having one Merge commit instead of three. How you ask? Octopus, My friend. All hail the great and mighty Octopus. So, the way you perform an Octopus is by merging all the branches at once on to the master. To do that you give a command like this

This will merge all the three branches to master. The branches will look something like this. Do you see the reference of Octopus now?

Now, if you know anything about octopuses, you might be wondering that we only have four legs here while an Octopus has 8. Well you are right. Octopuses do have 8 legs (technically 6 as two of them are used as hands) but 4 is good enough. Actually any merge can be called Octopus if you're merging three or more branches.

If you are using Git for sometime, you might be wondering, If Octopus is so freaking cool, why haven't more people heard about it and Why are more people not using it. Well, you are right my friend. Octopus is awesome for sure, but as I said it certainly does complicate things a lot especially when dealing with merge conflicts. Merge is hard enough as it is when dealing with just two branches. But if you are merging 5 or 10 branches together it feels like you're doing a complex surgery. You have to be really careful in that case and I am not even sure if any modern GUI tools support diffing 10-way. Also a lot of people tend to go overboard with Octopus.

Look at this message where Linus Torvalds yells (pleasantly) at a guy for creating an Octopus with 66 branches. Imagine that for a second. 66 branches! I wouldn't want to be the guy that handles merge conflicts on that one! Linux aptly says

that's not an octopus, that's a Cthulhu merge

So, a lot of companies don't really use this. A lot of people won't even consider this for their Merge strategies.

A rule of thumb to follow with Octopus is to never overdo it. An 8-way octopus merge though borders on crazy hard and insane, is fine but more than that is an overkill. The situations where you have to merge more than 5 or 6 branches tend to be very rare and in those cases may be you can go for an Octopus on a subset of branches at a time and do a Octopus for those. Or may be rethink your merging strategy.

Either way, I hope this article helped you in understanding something new and gives you some ideas for dealing with complex merges. I hope you will educate your peers and colleagues about this new merge and share this article with them

Well, That is all for this article folks. See you again in the next one. Until then, Good Bye.

October 13, 2016

This is the fourth article in the series titled, "Your First Lesson In Vim". These articles are written with a goal of helping out new Vim users by teaching the awesomeness of the Vim editor and there by extending the Vim community. Vim though quite powerful, has a bad rep for being hard to learn and hard to get started with. So, even when someone is interested in learning about Vim, that infamous learning curve seem to be scaring them off. This series is going to put an end to all of that.

In the last article Navigating in Vim I, we have seen a lot of Vim motions. Most of these fall under the category of word-motions (:help word-motions). We will learn some more motions in this article. And in case you still haven't tried Vim Adventures you should do it. It will help you a lot with getting the hang of Vim motions and getting around in vim.

Here are the list of Vim motions for this article.

Motion

What it does?

0

Go to the STARTING of the CURRENT LINE

^

Go to the FIRST NBC* of the CURRENT LINE

-

Go to the FIRST NBC* of the PREVIOUS LINE

+

Go to the FIRST NBC* of the NEXT LINE

$

Go to the END of the CURRENT LINE

g_

Go to the LAST NBC* of the CURRENT LINE

f{char}

Find a character FORWARD in the current line (Usage: to go to first occurance of c, you type fc)

F{char}

Find a character BACKWARD in the current line (Usage: to go to first occurance of c to the left of the cursor, you type Fc)

t{char}

Like f but places the cursor before the character (Mnemonic : t - till)

T{char}

Like T but places the cursor after the character

gg

Move the cursor to the first line (compare this with H)

G

Move the cursor to the last line (compare this with L)

* NBC - Non Blank Character

These motions let you move very fast between lines. You can go to any character you want on the current line with just 2 or at 3 keys, which is insanely fast compared to any other text editor. The last two motions (gg, G) are super useful and are certainly two of my most used commands.

Now we have one final set of motions to learn called Text Object motions (:help object-motions). Text objects is an important concept in Vim and we will cover that in depth in a future article. For now let's look at these motions.

Text Object Motions

Motion

What it does?

(

Go to the beginning of the PREVIOUS sentence

)

Go to the beginning of the NEXT sentence

{

Go one paragraph BACKWARD

}

Go one paragraph FORWARD

These four motions are very useful too. Especially if you're a programmer, the { and } will make navigating the code base a breeze.

And with that, we have covered all the basic Vim motions for you to get started. There is just one more important thing you need to know in conjunction with Motions. I haven't told you about this till now because I wanted you to get a full grasp of Vim motions before I explain this. Anyway, here it goes ..

Every Vim Motion takes a count before it

That's it. It might seem simple and it is simple, but its usefulness is just immeasurable.

Let's say you have to move eight lines down. To go eight lines down you don't have to frantically type jjjjjjjj. Just simply type *8j*. Similarly 4k to go four lines above, 6w to go to the sixth word from the cursor and so on. This is just such a useful feature that quite literally Sky is the limit for what you can do with this. Want to go to the second e after the cursor? Try 2fe and your cursor lands directly on e. Similarly to go to the ending of the 5th line below just do 5$ and B.A.M!

This opens up a whole new world of combinations for you to use and I hope you will make use of all of them. With these motions you can move to any place you want in the file with minimal number of keystrokes and your ultimate aim should be to accomplish everything with the minimum possible number of keystrokes. Be a Vim Ninja and conquer the world!

Well, That is all for this article folks. Will see you again in the next one. Until then, Keep practicing and Happy Vimming!

October 09, 2016

This is the third article in a series titled, "Your First Lesson In Vim". These articles are written with a goal of helping out new Vim users by teaching the awesomeness of the Vim editor there by extending the Vim community. Vim though quite powerful, has a bad rep for being hard to learn and hard to get started with. So, even when someone is interested in learning about Vim, that infamous learning curve seem to be scaring them off. Hopefully this series will put those fears to bed.

In the last article How To Exit Vim, we have seen what Vim modes are and what they do. So, If you know about Visual Mode, Insert Mode, Command Mode and Normal Mode, then continue with this article. Otherwise take a look again at the previous article. Vim modes are really important to understand this article and the upcoming ones.

I wanted this to be a part of the previous article but since this is really important and has a lot of potential information to discuss, I decided to give this its own full article. We will be spending most of our time in Normal mode here as that is where we will navigate in the file. You have seen how you navigate in Vim using h j k l. If you haven't figured out already, Vim's main philosophy is increasing your productivity and because of this some of the things Vim does might seem different compared to the usual way you are used to in other editors. Using h j k l is one of those things.

We have covered this in the last article but as promised I will expand about it here. If you look at your keyboard you will see that h j k l are on your Home Row (unless you are using Dvorak Keyboard, in which case this article probably won't help you much). Having the navigation keys on the home row is such an advantage as you don't have to move your fingers at all to access them. Going to the arrow keys for navigating is tiresome and time consuming. Don't think so? Well try it out yourself. Rest your fingers on their normal positions on the Home row (a s d f - j k l ;) and try to hit the UP arrow and come back. Did you see the travel involved in that? Do it again and see how you have moved your hand away from the keys and came back. Do it 5 more times and tell me If i am wrong when I say its just unnecessary travel, Especially since you have the navigation keys right on the home row in Vim. This is one of the reasons why Vim users are usually pretty fast. They don't keep moving their hands on and off the keyboard every time you have to go up or down. And again this could save you from potential RSI injuries.

So, I strongly advise you to stop using UP and DOWN arrow keys. To use the h j k l keys more, try playing Vim Adventures. Its a fun game where you go around the textland collecting characters using Vim's navigation controls. It will help you use the h j k l keys and just after a couple of tries it becomes muscle memory.

One more thing that you won't see Vim users (#VimRocks) using is Mouse. The argument against using Mouse is the same one as that for the arrow keys. You are taking your hands off your main row which not only breaks your typing flow but also is just plain annoying. Its the same for mouse except you're moving your hand even further which makes it that much worse.

Getting rid of Arrow keys and Mouse is not an easy thing. This is cert ainly something that takes time to get used to. But once you do, you will be that much faster in your work flow.

Vim Motions

Vim Motions are the amazing things that make Vim users so fast. You already know about h j k l. Motions are just about anything that moves your cursor from one place to another. Apart from that you also have w W b B e E H M L. Let's see what they do.

Command

What it does?

w

Move the cursor to the starting of the next word

W

Move the cursor to the starting of the next WORD

b

Move the cursor to the starting of the previous word (Mnemonic - back)

B

Move the cursor to the starting of the previous WORD

e

Move the cursor to the end of the current word (Mnemonic - end)

E

Move the cursor to the end of the current WORD

H

Move the cursor to the First line of the current visible screen (Mnemonic - High)

M

Move the cursor to the Middle line of the current visible screen (Mnemonic - Middle)

L

Move the cursor to the Last line of the current visible screen (Mnemonic - Low)

The usage of H M L commands should be clear with this image below. They move your cursor to first, middle and last line of the screen respectively.

To understand about w b e and their upper case variants we have to understand how word and WORD are defined in Vim. From the official documentation (:help word),

A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, )

A WORD consists of a sequence of non-blank characters, separated with white space

In short, a group of characters with out a space between them is a WORD and there can be multiple words in that. With that definition let's take a look at some examples and identify the number of words and the number of WORDS in them.

Word

# of words

# of WORDS

hello world

2 (hello,world)

2 (hello,world)

hello-world

3 (hello,-,world)

1 (hello-world)

hello_world

1 (hello_world)

1 (hello_world)

Once you understood the difference between word and WORD, all the motions explained in the first table would be clear. Just to make the foundation firm, try them out yourself. Type something in a file and try to see what each of the w b e W B E H M L commands are doing and how they are moving the cursor. All the motions we have covered in this article are called Word motions (:help word-motions). There are some more Vim motion commands that you need to know to quickly navigate with ease. To keep this article simple, we will end this discussion here and will pickup again in the next article where we will discuss about the other motion commands. So, Keep practicing these motions combined with other commands discussed in How To Exit Vim and you would be really fast already. Fast like a Puma!

Well, That is all for this article folks. Will see you again in the next one. Until then, Keep practicing and Happy Vimming!

October 02, 2016

This is the second article in the series titled, "Your First Lesson In Vim". These articles are written with a goal of helping out new Vim users by teaching the awesomeness of the Vim editor and there by extending the Vim community. Vim though quite powerful, has a bad rep for being hard to learn and hard to get started with. So, even when someone is interested in learning about Vim, that infamous learning curve seem to be scaring them off. This series is going to put an end to all of that.

In the last article Introduction & Installation we have seen why Vim is the best and coolest editor ever. Hopefully after watching Damian Conway's YouTube video given at the end of that article, you would agree. In this article we will experience Vim for the first time. We will learn about the various modes of operations in Vim. And, most importantly as the title of the article suggests, we will learn How to Exit Vim.

First thing's first, You have to open Vim, duh!. You can do that either by directly searching for Vim in your Search box or by typing vim in to your terminal. If you want to start off with gvim then open that instead. Your Gvim or Mac Vim would look something like this.

If you have already tried to type something, you would observe that there is something shady going on here. For example, if you type hello world you might observe that only world is displayed and hello is no where to be seen. Try it out for yourself. This happens because of the infamous Vim modes. One of the first things you have to realize while using Vim is that its not like your typical run of the mill text editor. Vim works a bit differently and Modes is one of the key things that makes vim different. So, let's take a look at them.

Broadly speaking Vim has Four major modes of operation. That number keeps changing depending on who you're talking to because there are a few more modes that can technically be called sub-modes but some people insist on treating them as Seperate modes. But to keep things simple here 4 is the magic number for you and 4 is the answer to Life, Universe and Everything. Not 42, 4!

The modes are :

Normal Mode

Normal mode is the default mode you will be in when you open Vim. Normal mode is used for altering, deleting and formatting text. You won't be inserting any new text into the document in this mode. Normal Mode is the mode you will be spending most of your time in. You can get to Normal mode by pressing ESC from any other mode. One of the main things you will be doing in this mode is moving around your document.

To move around the file in the window you might usually be using arrow keys. In Vim they will work the way you expect them to, but instead vim advises to use h .. j .. k .. l for moving the cursor. The reason why this came to be and the advantages of this will be apparent in the next article but for now let's see how this works.

h moves the cursor left, l moves it right

j moves the cursor down, k moves it up

This following picture would make the idea clear.

If you are thinking to stick with the arrow keys instead of h j k l, it is fine. There are a lot of people who use vim this way. But trust me when I say using h j k l speeds up you work flow a lot. Once you get used to this you wouldn't want to use arrow keys anymore. But anyway we will discuss more about the this in the next article.

Working in Normal mode, you will see how everything you do get's easy in Vim. For a quick sneak peak of some commands.

Command

What it does?

dd

delete the current line

yy

Copy (yank) the current line

p

paste the copied text below the current line

u

Undo your previous change

gg

Go to the beginning of the file

G

Go to the end of the file

From now on you don't have to awkwardly select the full line with your mouse to delete it. All you have to do is press dd and that sucker goes away.

Didn't mean to delete it? No problem. Just hit u and it undoes the delete. No more holding down Ctrl and z. Alsou for undo is so simple to remember. What does Z even mean in Ctrl + z? And how did that become synonymous to Undo?

Similarly no more Ctrl + c and Ctrl + v to copy and paste. yy and p got you covered.

So you see, Vim sticks to its philosophy of making you productive. Imagine all the keystrokes you save per day, per year. So, switching to Vim doesn't just improve your productivity, it take care of your health too. With every Key you saved keeps you a key away from getting Carpel Tunnels and RSI. So, Use Vim - Stay healthy. :]

You might be happy with using Ctrl+c to copy and Ctrl+v to paste in your plain old editor. Its absolutely fine but Vim offers a simple and easy alternative and honestly the choice is pretty clear.

Anyways, that is about Normal mode for now. We will discuss more later when required. Let's look at Insert mode.

Insert Mode

As the name suggests Insert mode is where you will inserting text and that is all you will be doing in here. You enter Insert mode by pressing i in Normal mode . And in almost all Vim distributions you should see a noticeable change in the cursor right away. It would have changed from a block type cursor (█) to a I-beam (|). That's your indication that you're in Insert mode. In another tutorial we will see how you make that even more apparent. Whatever you type in Insert mode would be displayed on the file literally. If you type a b c, it types in those characters in to the file as you would expected. Contrast this from pressing dd in Normal mode which doesn't print them on the file but instead does something to the file (In this case, a delete operation).

Unlike other editors you wont be spending much time here and Infact I'd advise you to get out of Insert mode once you are done typing. To go out of Insert mode you just have to press Esc and you will be back in Normal Mode.

Now, Let's get to the fun part of insert mode. Remember before when I said you go from Normal mode to Insert mode by pressing i, well, It turns out it is just one of the ways to get in to Insert mode. There are five more ways in which you can enter Insert mode and you can choose the best one based on what you need. Sounds complicated? Let's list them down first.

Command

Operation

i

Enters Insert mode with the cursor placed before the current character

a

Enters Insert mode with the cursor placed after the current character (Remember a - after)

o

Enters Insert mode by opening a new line below the current line (Remember o - open)

I

Enters Insert mode by placing the cursor at the beginning of the line (Remember big I - bigger version of i)

A

Enters Insert mode by placing the cursor at the end of the line (Remember big A - bigger version of a)

O

Enters Insert mode by opening a new line above the current line (Remember o - open)

As explained each one has a specific purpose.

If you want to quickly create a new line above the current line and start typing - You press O

If you want to insert a new line below the current line - You press o

To add something quickly at the end of a line - You press A

To add something at the beginning of a line - You press I

Could that be any more simpler? Surprisingly none of the other popular text editors do this. I can promise you that you won't be able to move so quickly in any other editor. This is Vim's power.

Let's look at another easy mode that will help you visualize things better, Enter Visual Mode.

Visual Mode

If you have carefully looked at things till now you might have started to feel that Vim favours Keyboard commands using a mouse. If you thought so, you would be absolutely correct. So, in the spirit of No Mouse, Visual mode tries to emulate Visual selections of your text similar to the way a mouse selects on Screen but instead with completely with the keyboard.

To enter in to Visual mode, just press v and move your cursor with either h j k l or the arrow keys and you will see that the text is getting highlighted indicating that it has been selected. Now, what can you do on this selected text? You can press d and delete it completely or you can press y and copy it. Notice that these are d and y and not dd and yy like in Normal mode. With v, Visual selection happens character by character. But if you want to select the full line, press V instead and you have the whole line highlighted and you can delete, copy or run any other command on the highlighted text.

This is how it looks like when you've something selected in Visual mode.

And to exit out of Visual mode or to cancel the selection, just press ESC.

Command

Operation

v

Visual selection by character

V

Visual selection by line

We are finally down to the last mode, which is the Command mode (You don't take Command, Son)

Command Mode

Vim command mode is very powerful and one of the reasons why Vim is so versatile. Command mode is where you type Vim's commands, Vim configurations, Plugin settings, Open new files, close existing files and also access Vim's builtin help documentation. You enter to Command mode by typing : and then you type in the command you want. After you press : you will see the cursor at the bottom of the screen (called the last line appropriately) and you type the command.

To open a file, you type in :e file_name (:e is short for :edit)and hit Enter. If the file exists Vim will open it for you and if doesn't exist Vim will open blank file for you and the file will be created when you save it.

To save or rather to write the file to disk, you do :w and hit Enter for it to be saved. If the file doesn't yet have a name, You type :w file_name and it will save the contents of the window with that file name.

And Now for the most important question in all of Vim's History and the given title of this article, How to exit Vim! If you are using a Graphical version of Vim, then closing Vim is the same as closing the window and poof, its gone. But If you're using a terminal (works in gvim and macvim too) then you quit Vim by typing :q (short for :quit) and that closes the current window. If you have unsaved changes in your buffer Vim will give an error saying No Write Since Last Change. If you don't mind discarding unsaved changes, you append a ! and so the command becomes :q!. That is all there is about how you exit Vim. The bang(!) at the end is similar to -f or --force option in a lot of linux commands. It forces Vim to quit even when there are unsaved changes.

From now on if you ever saw a meme like this, you know what they are talking about.

Another important Vim command is :help. It contains the full help manual for Vim and so should be one of your most used commands in the initial days of learning.

And similar to other modes, you exit command mode by pressing the Esc key and you will be back in the Normal mode.

This image illustrates how you switch from one mode to another

Okay. That's a lot of information for one article. Let's do a quick review.

Story Recap

There are four modes of operations in Vim.

Normal Mode : moving around the document, deleting, copying, formatting are some of the common things you do in this mode

Insert Mode : Inserts text in to the document. Go into Insert mode by typing any one of a A i I o O in Normal mode. Come out with Esc

Visual Mode : For visually selecting the text. Enter with v or V and exit with Esc

Command Mode : To execute commands. :w to save, :help for documentation and :q to quit.

Well, That is all for this article folks. Will see you again in the next one. Until then, Keep practicing and Happy Vimming!

September 24, 2016

This is the first article in a series of articles titled, "Your First Lesson In Vim". These articles are written with a goal of helping out new Vim users by teaching the awesomeness of the Vim editor and there by extending the Vim community. Vim though quite powerful, has a bad rep for being hard to learn and hard to get started with. So, even when someone is interested in learning about Vim, that infamous learning curve seem to be scaring them off. This series is going to put an end to all of that.

Warning : After going through all the articles in this series you will love Vim so much that you would like to have Vim style keyboard bindings everywhere, in your browser, in your mail client, in your shell and every other place which has a text input, which might not always be possible. So, Continue further at your own risk. YOU HAVE BEEN WARNED!

Vim is one of the best text editors available out there in the market. In fact it is one of the two best editors, the other being Emacs (This would be the last you'll see its name. From here on, it will be referred to as, The Editor which shall not be named ). Now you might be wondering, what about Sublime Text ? or Atom ? or some other flashy editor that's getting attention. My answer to that is very simple - East or West, Vim is the best. Don't get me wrong, editors like Sublime, Atom are good and I was a fan of Sublime myself. But to be called the best, a Text Editor needs to customizable, extensible and most importantly should have a huge community of users helping out each other. None of these editors can beat Vim in those areas. Apart from that Vim is really fast and robust. It can open huge files that makes other editors crash. It has builtin syntax support for hundred's of file types. It has a huge plugin base that both extend vim's functionality and add more functionality to do pretty much any thing you want. And that's just a few reasons why its the best.

Since you are reading this article, I assume that you're interested in learning about what Vim is and about what Vim does. So, Let's start with some brief history of how the Vim editor came to be.

In 1970's, Bill Joy developed ex editor for Unix which later came to be known as the Vi editor for having a Visual interface for editing.

1987 - Stevie was developed as a clone of Vi for Atari ST systems. Stevie stands for 'ST Editor for Vi Enthusiasts'. The name might be a mouthful but the editor itself is quite popular.

1988 - Vim (Vi IMitation) was created by Bram Moolenaar (Remember the name ..) as a port of Stevie for AmigaOS. Though started as an imitation, Vim quickly started to add several new features with support for multiple operating systems.

1993 - Vim 2.0 released with name changed to 'Vi IMproved' because, by then Vim had a lot more features than original Vi.

.

. Fast forwarding history

.

2006 - Vim 7.0 released with support for tabs, code completion, undo branching and a lot more

2016 - Vim 8.0 released with a lot of exciting features like Asynchronous I/O, channels, Jobs, Timers, Packages and a lot more

So, as you can see from our brief Time travel, Vim has been around for almost 30 years. Now you might be asking yourself, why the heck is this editor still used today after almost 30 years. That's a good question and one that needs to answered right now.

Technology sure changes a lot and old things usually tend to get lost with all the new things that keep coming. But in the case of Vim or The Editor which shall not be named, that is simply not the case. They fall in to the category of "Old is Gold". These editors are written during the days when floppy disks and magnetic tapes were all the rage and hence are written to be memory efficient. Though Vim has changed a lot over the years to add countless new features, the fundamental idea of being light weight and memory efficient is still one of its big selling points. That is the reason why Vim managed to stay relevant through three decades and that is also the reason why it will continue to be relevant for more decades to come.

So, If that answer convinced you to stay the course and explore the exciting and enticing world of Vim, then Welcome aboard! Make sure to remember that this is the day you have decided to take your text editing to the next level by learning Vim.

Now that we know the history of Vim, its time to install Vim on your Computers. If you are rocking a Linux Operating system, chances are you already have a version of Vim pre-installed. So, check if it exists by typing vi or vim in the command line. If it is available, you should see a screen that looks something like this.

If you see this then Vim is already installed.

If you don't have it installed, don't worry. Vim is a freeware (correction: Charity ware) and so you can download it for free from Vim's official site Vim.org. Vim is available for pretty much every major Operating system out there. I heard that there is a version of Vim available even for Toasters. I have no idea who might use that, but its there if you need it. And this is another reason why people like vim so much.No matter the OS, they can be sure that their favorite editor is available. So, Just download vim for your operating system and install it.

And by the way, did I mention that Vim is primarily a terminal based program? It was initially designed to be run in terminals to access files on remote systems. A lot of people to this day, prefer the terminal version of Vim. But to those of you who like to have a Graphical User Interface (GUI) you've that available as well.

For windows users, it can be downloaded from the vim.org site. Look for Gvim (stands for Graphical Vim) For mac users, you can download Mac Vim which provides a good GUI experience. For Linux users, there are Gvim versions available for most of the distros. So, download the one suitable for your distribution.

If you have successfully installed Vim on your systems open Vim either in Terminal or the GUI and you should see a welcome screen similar to the picture above. If you got that, then Congratulations, you have the power of Vim with you now.

Don't forget what Uncle Ben said, "With great power comes, great responsibility". So, your responsibility as a Vim user is to spread the vim awesomeness with your co-workers and friends. It would be even better if you can share this article with them but that is entirely up to you. (Jedi mind tricks working implicitly)

And before we finish this article I will give you a sneak peak at the power of Vim and what you can do with it. Watch Damian Conway's Video on Vim : More Instantly better Vim. Conway is one of the Vim geniuses whom I admire a lot. This video gives you a small window in to the world of Vim and what Vim can do in the hands of a seasoned user. You might not be able to understand understand how Conway is doing his magic but that is entirely fine. You obviously won't be able to understand Linux Kernel module code right when you're starting to write Hello World programs. This video is just to show you how the masters use Vim and you will be able to do that too once you've mastered it.

Well, That is all for this article folks. Will see you again in the next one. Until then, Keep practicing and Happy Vimming!

July 18, 2016

Using Tabs (vim calls them tab pages) is one of the sure ways to increase your productivity. Vim Tabs are just like the tabs in your browsers. Each tab can have multiple splits (referred as windows in Vim's documentation). So, you can have multiple splits open in one tab and then you can have multiple tabs.

Tabs are a really handy way of grouping things together. So, I usually have multiple tabs open in any session. I have a main editor tab where i will have multiple splits open for the code I am looking at and since I work with a lot of data files, I will have one tab dedicated for the data-sets that I will be using for my program. And, then if required, I will have another tab open for any notes, info that I have previously noted down.

June 23, 2016

Apache Spark is becoming ubiquitous by day and has been dubbed the next big thing in the Big Data world. Spark has been replacing MapReduce with its speed and scalability. In this Spark series we will try to solve various problems using Spark and Java.

Word count program is the big data equivalent of the classic Hello world program. The aim of this program is to scan a text file and display the number of times a word has occurred in that particular file. And for this word count application we will be using Apache spark 1.6 with Java 8.

If you had asked me this question a couple of months ago or even just a month ago, my answer would have been Hillary Clinton without any but’s and if’s attached. But now, Its quite unclear.

I have been following this election from the beginning and I predicted it would be Hillary Clinton Vs. Trump for the final, long before others did. And, I assumed Hillary would win it in the finals very comfortably. But, What a ride it has been! It has become such a close call these days and rightfully so.

Map and FlatMap functions transform one collection in to another just like the map and flatmap functions in several other functional languages. In the context of Apache Spark, they transform one RDD in to another RDD.

Vim is one of the most powerful text editors available. And, hence it is not really possible for everyone to know everything or get the same ideas on improving their work experience. And, so this article includes a few tips and handy shortcuts that will help your productivity just as we have been doing in the Vim series, but individually not extensive enough to get their own dedicated article.

A lot of Programmers use Vim in some way or another but a vast majority of them use only a handful of features. Knowing to use Splits, tabs, macros and marks can really increase your productivity. Through this and the upcoming articles on Vim I will try to cover the important things that make Vim so awesome.

Splitting your Screen
Vim Splits is a very powerful way of keeping your workflow organized. You can use splits (windows or view-ports in Vim vernacular) to get a different view in to the same file or open a different file to see a quick diff .

Xargs is one of the really useful Linux commands that every one should know about. It is a great command that simplifies your task at hand and overall, a great command to have in your arsenal. And, its quite simple to use.

So, What is xargs?

Xargs is a command that helps you run a command on a series of things in order. The easiest way to understand this is by looking at an example. Before, that here is the typical command structure when you use xargs.

We have already seen how to use the dot operator in Regular Expressions in the last tutorial (Link). To see all the articles of this Regular Expressions series, click here .

In this lesson, we will see what to do when some characters you want to match are optional, i.e., if they are present, match them and if they are not, don't bother.
So, Imagine a situation where you want to match foo and foobar. Hence, bar is optional. Then, what do we do to match and identify such words? Let's see ...

Vim never fails to surprise you with the amazing features it has in its arsenal. Very recently I have found that Vim comes bundled with an encryption mechanism referred to as VimCrypt.
It is always a good practice to encrypt your files especially when it contains personal or sensitive information. I often write my Daily journal notes in vim and i always encrypt them with some external programs. But, Vim itself is capable of doing that.
Let's see how it works.

Let's continue with Regular Expressions. All articles in this series can be found here. I will be using Regexr.com for most of these tutorials. It is a great site, where you can write and validate your regular expressions against your desired input text.

Read Line is a editor every body uses but no one knows about. If you have used Linux for anything before, you have used ReadLine. Doesn't ring any bells? Well, that is because, not a lot of people call it that. It is more frequently termed as the "Bash Prompt" or something along those lines.

dsp@freblogg:$ |

So, this prompt you see every time you open a terminal, has got a name. Its called ReadLine. A really lax name, isn't it? No wonder it didn't catch on.

So anyway, here are a few keyboard shortcuts to help you type efficiently in ReadLine and become a Con-fu master!

Regular Expressions or RegEx is a sequence of characters that define a search pattern. Regex is every where these days and you can use it to extract information from Text files, Log files, Dictionaries, Spread sheets and even webpages. Every major programming language has support for Regular Expressions. Most importantly grep, awk and sed use regex to find/replace matches.

Regular Expressions can help you save a lot of time. Instead of writing complex String pattern searches which span over multiple lines, regex gets the job done really easily and really fast.

NERDTree is a real time saver and a pretty cool extension to your Vim setup, to make it more user friendly. Almost every other Text editor out there comes with an ability to show the file directory listing in which the current file is present. And, if you are wondering how you can do the same in Vim, then look no further because NERDTree is what you want.

So, what does it do?

It just shows all the files, folders in the current working directory. Also, you can add,delete files right from the list. That's pretty cool.

Switch Case is certainly one of the most widely used programming constructs. It is just as widely used in Java as in any other language.

Up until Java 7, switch in Java did not support String type in the case statement. So, if you want to perform multiple comparisons on Strings, the only way you were able to do it was by using multiple If - Else Statements which is certainly not pretty!

But, then in Java 7 they have introduced Switch With Strings and it was welcomed by everyone who had to write those terrible if-else ladders. So, Let’s see how we can use Strings in a Case statement.