My vim setup

kenken17
4 min readAug 14, 2018

--

I have been using vim for like half a year now. I come into conclusion that:

  • Not many friends/colleagues around you will be convinced to use vim, actually not even one for me so far :( ;
  • vim is not the ultimate all-in-one IDE, at least not for everyone;
  • vim is just another editor for coder, it might increase you productivity, but not by a margin, you need years of tweaking/using before you reach that margin; and
  • indeed no mouse is needed for coding :).

I have been reading/watching quite some articles/videos about vim that possibly found on the public internet in this year and half, and have been tweaking my workflow slowly to increase productivity (it is a journey for all vim-er) I assume.

My intentions/goals to switch from already-well-versed Webstorm/PhpStorm to vim, can only be fulfilled if I could do the below in the same/ faster/ better/ easier way, else no point to switch:

  1. Editing with ease, which includes syntax highlight and day-to-day editing.
  2. Search and replace, crucial;
  3. Source code control (git), which includes basic commit, pull and push, also merging and diff-ing; and
  4. Project/files navigation.

When you are trying out a newly found plugin, you might change your workflow or coding style (I am actually enjoying the changes, coder easily get bored, you know!) to adapt the plugin’s behaviour. I am quite happy with my current setup. Below are plugins (the main ones) and setup I currently using.

Editing with ease

No plugins needed but with some user defined key mappings to help code editing more efficiently. Vim natively has the speed come right out of the box. Without switching context between mouse and keyboard provides the ability for typing without distraction, therefore increase speed of editing.

For syntax highlight and colour code, I have made myself a simple-tone theme that took inspiration from some other monochrome themes. It is simple and non distracted. I am quite happy with it. Looks something like this:

home-made simple-tone theme

In order to work with front end coding, there are plugins that you need to install for better syntax/auto-complete.

I bet no one would like to type the same variable/name again and again when coding. So auto-complete is definitely a must nowadays. I have been using youcompleteme for the first year but found it heavy/sluggish. Now I am settle with vim native auto-complete combine with some help from:

  • ervandew/supertab: Using a tab for auto-complete is kind of burned inside a coder mind. So we need some help from this plugin. Native vim auto-complete is not that user-friendly.
  • SirVer/ultisnips with honza/vim-snippets: Snippet completion is a boost in coding, especially you are doing similar code template day in day out.
  • mattn/emmet-vim: I believe you must have heard about emmet, previously known as zen coding. This is a quick way to expand html/css tags and properties. Not a big fan, but having it for adhoc expanding.

Search and replace

The native `/` is helpful for searching within file, but not for the whole projects. `:%s` is helpful for search and replace, but suffered from the same issue. At last I have come to ACK for saviour.

  • mileszs/ack.vim: It’s just a wrapper for ACK on the system. So you will need ACK on your machine before you can use this plugin. I found it fast and easy to user. Have a key mapping for quick search for word under cursor, or entire project will make it even more coder-friendly.

Source code control (git)

I don’t think there is any plugin better than Tim Pope’s fugitive plugin for git. Although it just a git wrapper, it does make my life easier for day-to-day commit and push codes.

  • tpope/vim-fugitive: I am using this for commit, pull/push and diff. With some colour coding for diff, it’s easier to edit between changes of files away from the HEAD.
  • cohama/agit.vim: For history/logs, I am current set for agit, since it has slightly better visual presentation than fugitive’s log. Unfortunately, agit does not come with diff for files on the log. I am still not able to find any plugin that show logs/history with diff of files. :(

Project/files navigation

Able to jump around within a file or switching among files in a project inevitable for a coder, after all, we work on a lot of files! So we need some boosts.

  • ctrlpvim/ctrlp.vim:Quickly switching amount buffers(files) is a must. with the fuzzy file search and MRU (most recent used), I can jump to a file that I need to work on within 2–3 key strokes.

There are still more plugins on my list, but above are the major ones, and others are small helper plugins, which contribute to the whole coding experience nonetheless. We could have another post to discuss those. ;)

--

--

No responses yet