DEV Community

Aadesh Shrestha
Aadesh Shrestha

Posted on

Beginning Vim

For a long time, I had been "thinking" of learning vim. The first thing I tried was 'vimtutor' which was quite easy to get started with but at the same time, I could not grasp all the things taught in it. The very mistake I made in going through vimtutor was trying to learn all the commands at the same time. And also it was due to my keyboard layout (colemak). The k, l, h, j keys are quite not in vim "order"

After completing the vimtutor I tried using vim but with no success. I kept getting stuck at small tasks like copy and paste, changing modes. After using for some "hours" I got this feeling of being less productive. So I eventually gave up the idea of "learning" vim.

Few months later I again had this hunger for learning vim. To make sure that I don't give up like the last time, I asked couple of my friends( Swojeet and Rabin ) to try and learn vim together. We printed the vim cheatsheet and also learned few vim configurations. Now after 2 months of using vim with the minimum configuration as possible, I can confidently say that I'm quite comfortable with VIM. I'm still a long way to be able to do things like pro but I understand that it'll take time.

If you are also trying to learn vim and are stuck in exit, you should get a friend with whom you can learn it.

Vim Configuration

Looking forward for suggestions.

Top comments (10)

Collapse
 
jorinvo profile image
jorin

Learning vim is a hard but rewarding challenge :) Glad to see you manage to overcome the first hurdle!
As you are comfortable with the basics, I recommend having a look at this answer here. You might have understood this already, but I recommend everyone that uses vim to have a look at this to make sure they understand the essence of how to be productive using vim. It also contains some good examples. It definitely helped me a lot to get motivated in the beginning :)

Collapse
 
aadeshere1 profile image
Aadesh Shrestha

Thanks Jorin for this recommendation. It would be very helpful for me. Could you also take a look at my .vimrc file on github and recommend what more should I be adding on that ?

Collapse
 
jorinvo profile image
jorin

I think configuration is something really individual and you have to find out what works well for you.
I try to keep my configuration minimal and only add things I understand.

You chose a nice plugin manager with vim-plug. You can also tell it to only load packages for certain languages to speed up loading, like this:

 Plug 'https://github.com/fatih/vim-go', { 'for': 'go', 'do': 'nvim +GoInstallBinaries +qall' }

If you feel comfortable with the features you use and like to learn something new, I recommend having a look at the :terminal feature that comes with Vim 8 and also NeoVim.

Keyboard shortcut mappings are one of the most subjective topics. Personally I prefer mapping unused key combos instead of using <Leader>, but you have to find out what works best for you.
You can have a look at my configuration if you search for some inspiration.

In terms of plugins my favorites are fugitive + gitgutter for Git and surround, commentary and unimpaired for great new shortcuts/functionality that I use every day. But better don't start using them all at once :)

Also remember that you can always lookup help:
What does this plugin do? :h fugitive
What is this shortcut? :h K

Collapse
 
sallar profile image
Sallar

I have tried as well. But I don't really get the point of using Vim as my main editor. I can do simple edits with it when I have to (eg SSH) but for my daily work, I prefer a better editor like VSCode, Atom or Sublime. Why would I waste the time I can be earning money or learning something better just to learn how to use an old editor so I can type faster or look cooler among devs? I like having the luxury of extensions, intellisense etc in my modern-day editor. But this is just my personal opinion.

Collapse
 
aadeshere1 profile image
Aadesh Shrestha

Thanks for your opinion.

Collapse
 
aghost7 profile image
Jonathan Boudreau • Edited

I can recommend some git utilities such as junegunn/gv.vim and tpope/vim-fugitive. Some commands I use from these plugins:

  • :Ggrep somepattern | cw: Searches file contents which are tracked by git.
  • :Gblame: Does a git blame from your editor. You can also go back in time by selecting the commit and pressing ~. O on a commit will open the entire commit in a new tab.
  • :Gbrowse!: (requires tpope/vim-rhubarb plugin on top of fugitive): Generates a Github link with the correct branch and file and puts it into your clipboard. Also works from visual mode.
  • :GV!: Displays the change history of the current file.
Collapse
 
ghost profile image
Ghost

One suggestion about your .vimrc. Instead of use kien/ctrlp.vim, use the oficial fork where the development is happening: ctrlpvim/ctrlp.vim.

Collapse
 
aadeshere1 profile image
Aadesh Shrestha • Edited

Updated. Thanks, Diego.

Collapse
 
kuzyo profile image
Yaroslav Kuzyo

After sometime working using vim(one year), I moved to vscode, but using vim keybindings (github.com/VSCodeVim/Vim)
I'm just started to feel that I'm spending too much time with vim configuration instead of just doing work.

Collapse
 
rossijonas profile image
Jonas B. R. • Edited

Duckduckgo.com has a very nice vim cheatsheet too, native to the search tool!!

cheatsheet

By the way, I started to write quick tips and tutorials for Vim beginners, to help them deal with specific configs and get excited with tricks you can use.

You can check it on medium.com/vim-drops !

Cheers!✌️👨‍💻⌨️👩‍💻✌️