Vim is Vi(Improve) editor. The learning curve is insane. Newly installed Vim is useless and you have to install and configure plugins. it is because its flexibility. My personal choice to vim is https://github.com/carlhuda/janus. It got almost everything I need out of the box.

Here are the vim command I learn over the weeks and I believe this list will keep growing.

Certain commands are prefixed with a key, which maps to \ by default. You can, for example, use let mapleader = “,” to change this to a comma. If you want this to be in effect for uses of in the .vimrc file, make sure to define this in ~/.vimrc.before

Install additional plugin

mkdir -p ~/.janus && cd ~/.janus && git clone URL

search and replace everything in an open file

:g/Text1/s//Text2/g

Turn on/off line number

:set nonumber or :set number

Show hidden files/folders in vim

shift+i

Show/Hide Nerdtree

ctl+b

Refresh Nerdtree

r

Create a new file in Vim/NerdTree, navigate to NerdTree

ma

Change root directory

C

To navigate to different window

ctl+w

Quick file search with live search

ctl+p
  • Press <c-f> and <c-b> to cycle between modes.
  • Press fn+f5 to purge the cache

Linux command line without leaving vim

:!Command line

List file buffer

:ls

Next buffer

:bn or :b#buffernumber

Next buffer

[b

previous buffer

]b

Resizing Vim split panel

ctl+v

Split a vertical panel

:vsp

Split a horizonal panel

:sp

Make current window panel full screen

:ZoomWin

Fix whiteSpace in vim

::FixWhitespace

In normal mode, type i and it will open a vertical split new panel

i

Automatically adding php namespacing(https://github.com/arnaud-lb/vim-php-namespace)

You have to install ctags

brew install ctags

Run the command below in laravel directory

ctags -R ./*

To use the autonamespace

,u

Commenting code using NerdCommenter

c #multiple line in Virtual mode
cc #one line

Snippet can be found here

https://github.com/honza/vim-snippets/blob/master/snippets/php.snippets

https://github.com/godlygeek/tabular

Aligning text

:tab /=

Go to line

42G
42gg
:42<CR>