Quantcast
Viewing all articles
Browse latest Browse all 10

Yet another Vim cheat sheet [personal]

Vin is the superseded text editor of VI, an historical utility of UNIX. It has been initially developed on the Amiga OS (the last offspring of Amiga?) and is now available in most of Linux distributions. If you are on this page you probably already know that. Vim has a steep learning curve. The first steps are not easy, but once you master a couple of commands, it is really handful and even powerful. You can do almost anything dealing with text file with it, and more specifically coding. You will find below my personal Vim cheat sheet.

Image may be NSFW.
Clik here to view.
Screenshot of a Python piece of code edited using VIM Yet another Vim cheat sheet [personal]

Screenshot of a Python piece of code edited using VIM

INSTALLATION

Vim can be customized at several levels, the first one being maintained in the ~/.vimrc configuration file. I found the following customizing helpful:

set background=dark
filetype indent plugin on

By default in Ubuntu, the syntax highlight is activated. By specifying that the background is dark, the Vim uses a dedicated set of colors. The second line tells to Vim to activated the indent plugin based on the type of edited files.

Python specific installation

This customizing is maintained in the file ~/.vim/ftplugin/python.vim. According to the Pyhton wiki page for Vim (see link bellow, for all the details), I have used the following values for a perfect Pythonic layout:

set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4

NAVIGATION

Move down: j
Move up: k
Move right: m
Move left: h

Go to end of file: G
Go to head of file: gg
Go to end of line: $ (useful with very large lines)

1/2 page down: ctrl-d
1/2 page up: ctrl-u

EDITOR MODE

Editor mode and insert before: i
Editor mode and insert after: a (better than i + move right)

Go to the end of line and editor mode: A

Omni completion: C-x C-o

Exit editor mode: ESC

COMMAND MODE

Delete character: x
Delete line: dd

Undo: u

Select text: v + move cursor
Select lines: V + move cursor

Copy (after selection): y
Cut (or delete) (after selection) : d
Paste after the current position: p

Keep one window: :only (you may open several windows using the auto-completion)

RESSOURCES


Viewing all articles
Browse latest Browse all 10

Trending Articles