git in 5 minutes

Yes you read it correctly,5 minutes.I will not be covering what is version control or what is git . We will directly get our hands dirty

  1. Init or pull
  2. Add (for init)
  3. Commit
  4. Pull-Push


init or clone

Here it starts, you want you use git for existing project which was not in any version control or clone a project.This is very first up terminal/cmd

$ git init

or you can clone a repo(a fancy word for code in VCS) in this’s how
you do it.

$ git clone

Lets move to next step.


So you’ve initialized repo in the current directory but your files are not being
tracked coz you haven’t said git to do so.In git terminology we say it staging
changes.if you’ve just cloned a repo, this step is not needed unless you’ve added
new files are did some changes to existing ones.

$ git status

run this command every now and then to see whats current status of your project.

$ git add .

This command will add all files in the repository.


Wait, In last step we did added changes right?. Whats with committing? .Think of
it this way,staging changes means you have prepared files to commit.Well people who
are gamers can think of commit as a save point.Once saved you know you can jump
back to save point,if you break something.

$ git commit -m "Write your commit message here"

Protip: use git status often

You will see a verbose output about what git is doing,read through if this is your
first time.


Great you’ve committed , now what.Now lets push the changes to server.But hold your horses
it a best practice to pull before you push.If you are only one who is making changes you don’t
have to worry about overwriting changes.Server can be anything [GitHub, bitbucket or any other]

git pull <remote_repo_name>

ex : git pull origin

Here some conflicts may occur like you have changed a file and other contributor have
done the same.So, compare files include or exclude changes and commit.Now you are good
to go.Lets push it

git push <remote_repo> <local_repo>

ex: git push origin master


This is like 70-80% of git you will ever need to know.Jump in and use you it your next project.
The infographic will explain if you didn’t catch my point.
picture below will explain





git-scm (

github (

bitbucket (


Language of VIM/NEOVIM

The first thing that may come to your mind when I say language of vim is Vim Script.No that’s not what I am talking about.I am talking about the patterns of keystrokes that recur over and over through your use of vim.


Construct <A> , Single alphabets

These are most common and most basic of all constructs ,It serves as main building block in vocabulary of language you are about to learn.It includes all the commands that are used in normal ,command mode and visual mode and macros also because they registers in disguise.


Construct <B>, [count]<A>

Construct B comes into picture when you want a action to be repeated several times.count or range is usually a positive integer.Almost every vim command supports repetition using count, there are some that behave differently form other, like appending a count to v or V will be multiplied 5 times the count or even entire file is selected if the file type is markdown .I don’t know why and or it is same with other types also.Works fine with text, php and python files,If you do know then please leave it in the comment section.

12: "and soo no


Construct <C>,<A>[motion] or <A>[i|a][motion]

In order fully understand the working of this construct, you must be familiar with types of motion that vim offers.I won’t be going over them.It is also important to remember that this construct will not work with all commands you can experiment this construct on different commands.This construct does not work with Macros and for some constructs motion is insignificant.

di} "or di{
ci] "or ci[


Construct <D>, [count]<C>

The fourth construct is extension of 3rd one,sometimes I wonder how a simple text-editor written in a period of early days of computation is capable of such complex operations and can compete with just any other editor or IDE. Okay , back to the topic.This is same as construct C, with an added ability to be repeated using count.



Construct <E>, [count]”[char]<A> in normal or ctrl-r[char] in Insert/command mode

The odd one out , this construct is different from previous ones.It allows for only yank and paste operations.There is a catch , range only works in normal mode.primary use of this construct is to edit or delete content of a register, well why you might want to do that ? because Macros execute the content of registers.By the way if you want to know more about registers , please check this post.Small letter will overwrite previous content if any and caps variant of the alphabet will append new data to the existing data if any.There may be cases when you recorded a register which is just right but not completely what you want it to be and you don’t want to re-record macro.You can paste the contents of register make the changes and yank it back to same register.

"Insert or Command mode
"Normal mode


:help motion
:help text-objects
:help count
:help @

Conclusion :

Your brain loves patterns and thing that can be easily related to what you already know. Vim is complex , you need years of practice to master it and even after all those year you find something that you didn’t know was possible or existed in vim.

"Normal mode 
"Insert mode
<c-r>a "The data inside registers is persistent

7 most useful vim mappings

01 Leader

Vim’s default mapping for leader is


most peoples remap it to

let mapleader=","

which I personally think is not a good choice.Remap it to either CAPSLOCK or SPACE key , and find out which works better for you.For me CAPSLOCK didn’t workout well.


In modal editor like VIM we constantly need to switch modes.Switching to normal mode vim uses esc key which to too far on my keyboard.And ctrl-[ is painful to reach out.So I’ve mapped it to keys available on home row.I might seem an overkill , using 2 keys to do a job that just required 1 key.But trust me you will thank yourself for dropping this mapping into your .vimrc file after few days.

imap fj <esc>
imap jf <esc>

03 : (command-mode)

If you are a regular vim user you might have felt that switching to command mode is requires you to hit 2 keystrokes.We can fix it by mapping : ; in normal mode.Hardly many peoples use semi-colon functionality .If I am right most peoples don’t even know what it does.

nnoremap ; :
nnoremap : ;

04 Function Key

We have function keys at our disposal, use your creativity and map it to either a command or combination or even vim functions.Below are a mapping from my vimrc

set pastetoggle=<F2>
nnoremap <F3> :noh<CR><CR>
nnoremap <F5> :set spell!<CR>

05 Shift+Function key

Yes you read it correct.You have more 12 keys to fiddle with and make your vimrc more awesome.if you are a programmer map function keys to compile and format code ,call linter. If you are using vim to write notes or write anything else map fn keys to help you out.Possibilities are endless.

nnoremap <S-F5> ggvG= "shift <F5> to format code

06 Arrow keys

If you are beginner map arrow keys to do nothing, i.e just disable these keys.So that you force yourself to use vim as it is supposed to be used.

noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>

If you are already in the habit of using hjkl keys to navigate.these mapping are not of much importance to you. Level 2 user can map arrows keys to navigate windows.

map <Up>   <C-W>k
map <Down> <C-W>j
map <Left> <C-W>h
map <Right> <C-W>l

07 Tab

Tab key in normal mode is useless.Map tab key to switch tab.Tab to switch tab, hahahahaha. Below is the vimrc snippet that will help you do that.

nmap <tab> gt
nmap <s-tab> gT



Its not actually my idea.One guy at reddit has posted comment about it.It is actually very convenient to map CTRL to CAPSLOCK .Thank him for sharing his thought

wrapping up

I have focused only on the things you need to often in any text editor.There are a lots of articles out there which show you mapping to do just about anything.

Registers in VIM/NEOVIM

There are ten types of registers:

  • Unnamed register “”
  • Numbered registers “0 to “9
  • Small delete register “-
  • Named registers “a to “z or “A to “Z
  • Read-only registers “:, “., “%
  • Alternate buffer register “# (neovim considers it as RO reg)
  • Expression register “=
  • Selection and drop registers “*, “+ and “~
  • Black hole register “_
  • Last search pattern register “/

unnamed register “”

Vim uses unnamed register as the default register.It used for all delete , change , copy , cut operations also It points to the last used register unless last used register is Black hole use it very often. Whenever you use y/Y or p/P commands , you are using unnamed register.It is still surprising to see name for an unnamed register.It can explicitly accessed using “” in normal mode or ” in insert mode

Numbered registers “0 to “9

Vim gradually fills up these registers as you keep using delete and copy(yank) commands.So what do I mean by that , with each successive deletion or change, Vim shifts the previous contents of reg 1 into reg 2, 2 into 3, and so forth, losing the previous contents of reg 9.

  • reg 0 contains most recently yanked text
  • reg 1 contains most recently deleted text

Small delete register “-

This register contains text from commands that delete less than one line, except when the command specifies a register

Named registers “a to “z or “A to “Z

These register are like your treasury ,they only be filled or used only when you specifically order VIM. Text can easily appended to these registers.You use small-caps to overwrite previous text if any and Upper case to append to existing text. Uses

  • Macros
  • Multi-clipboard
  • persistence

Read-only registers “:, “., “%

We have 3 Read-Only regs,you can only use them on 3 variants of one command.How co-incidental.p,P,:put are the only privileged commands known to have access rights to read-only regs.

  • ". /(dot command /) Everyone who have used VIM for more than a week know what I am talking repeats last insert operation.
  • ": Stores most recent command line command.if you are curious to see its contents, use <c-r>: in more trick,used @: to repeat last command.
  • "% Stores current file name, a very unusual feature that I missed in every editor I used other than VIM.

    Alternate buffer register “#

    This comes in play when you have more than one file opened in VIM.Stores name of the alternate file for the current window.It will change how the <c-^> command works. This register is writable in VIM but read-only in NEOVIM.

update :

This register is now made writable as a fix to the issue : link . Thanks this guys here for this info

Expression register “=

I call this one as built-in calculator that is bundled with VIM, again a feature that I miss in other editors and IDE’s I use.This is not really a register that stores text, but is a way to use an expression in commands which use a register.This is one of those register with its own special history.It is a little tricky to use, but once you get the hang of it,your productivity will get a pretty decent boast.To access it hit = after <c-r> in insert mode or ” in normal mode, doing so will drop me on command line,I now have all the power command line has to offer.

Selection and drop registers “*, “+ and “~

Stores and retrieves the selected text from the GUI.

  • "* Holds text copied to system clipboard, if VIM has this feature enabled
  • "+ This is synonymous with * under windows but distinct in Unix(x-11) based systems
  • "~ People familiar with unix based systems may think of this one as home directory for current user.It is read-only register, strange right.I wonder why it is not included in Read-only reg list.Register stores the dropped text from the last drag’n’ drop operation. When something has been dropped onto Vim, this reg is filled in and the pseudo key is sent for notification.It is highly possible that you are ever gonna use it.

Black hole register “_

It is what it say, anything sent to it is lost forever.*nix user can think of it as /dev/null.Cool awesome example, just popped up at perfect moment.

Last search pattern register “/

Here come one more extremely useful register,ever wondered how vim could remember tons of your searches. It is a RW register value can be assigned using let Vim script anyone.

We will wrap up now.Before we do here are few commands that can help you use register better.

 :help registers
 :help quote_quote
 :help quotenumber
 :help quote-
 :help quote-
 :help quotealpha
 :help quote.
 :help quote%
 :help quote:
 :help *quote#
 :help quote=
 :help quote~
 :help quote=
 :help quote
 :help quote/
 :help @/

%d bloggers like this: