Notebook of Vim

Start Vim Tutorial

$ vimtutor

Start vim with explorer window to navigate among files and folders

$ vim -c Explore

Start vim with an Explorer aside

$ vim -c Lexplore

Get into command mode


Enter command in Command Mode


How to quit without saving


How to quit with saving (write)


How to move around in the editor

←:[h], ↓:[j], ↑:[k], →:[l]

How to undo


How to change a letter


How to delete a letter

How to copy line


How to cut a line


How to cut multiple lines, like 3 rows


How to paste


How to select letters (Visual Mode)


How to select line


How to set line numbers in the editor

:set number

How to start searching


How to search string


How to find and replace some_letters to another_letters in the current line


How to find and replace in the entire document (globally)


How to select block (Visual Block Mode) from the cursor position


How to increase of code line (opposite key for vice versa)


How to increase indent of code block / multiple lines (opposite key for vice versa)


How to execute vim commands for a file outside (in CLI) of vim

$ vim -c <"command">


$ vim ~/.bash_aliases -c ':s/alias lll="ls -lash/alias lll="ls -lashR"/g' -c ':wq'
finds and replaces alias; quit

How to insert date and time

:put =strftime(\"%Y-%m-%d %H:%M:%S\")

How to split window into panes

That command opens a file by splitting the window horizontally to top
:split <filename>

How to resize panes

:res <number to specific size>

How to resize pane 5 chars to right side


How to resize pane 10 lines down


How to run pyhton code inside vim

:w !python

Some strftime() format string examples

Format String              Example output
-------------              --------------
%c                         Thu 27 Sep 2007 07:37:42 AM EDT (depends on locale)
%a %d %b %Y                Thu 27 Sep 2007
%b %d, %Y                  Sep 27, 2007
%d/%m/%y %H:%M:%S          27/09/07 07:36:32
%H:%M:%S                   07:36:44
%T                         07:38:09
%m/%d/%y                   09/27/07
%y%m%d                     070927
%x %X (%Z)                 09/27/2007 08:00:59 AM (EDT)
%Y-%m-%d                   2016-11-23
%F                         2016-11-23 (works on some systems)
RFC822 format:
%a, %d %b %Y %H:%M:%S %z   Wed, 29 Aug 2007 02:37:15 -0400
ISO8601/W3C format (
%FT%T%z                    2007-08-29T02:37:13-0400
Source: Vim Tips Wiki


Character Sets useful in vim

Use \r instead of \n to enter newlines, for example during a find&replace. Command below with the shortkey set finds null characters (^@) and replace them with newline in the entire document.

How to install plugin with Plug

Install vim-plug for Linux (Windows requires another command in powershell):
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs

Download desired plugin
$ git clone ~/.vim/bundle/vim-solidity

Edit ~/.vimrc, add begin and end lines for the plugins requested to add.
call plug#begin([plugin_directory])<br>Plug 'tomlion/vim-solidity'<br>call plug#begin([plugin_directory])

Set EOL for dos/unix up

:set ff=<dos/unix>

Start the Discussion!Leave a Reply