Navigate back to the homepage

How the hell do I exit! Guide to Vim

Nancy Chauhan
February 15th, 2019 · 2 min read
1ESC? Nothing happens.
2
3CTRL + C? No.
4
5ESC ESC ESC? Nope. I'm stuck.
6
7How to quit?

Sound familiar?

I don’t know about you, but I’ve been there. Until I decided to spend 10 minutes learning the very basics of Vim. This post is just enough to get you started and do not covers advance !

Vim is there by default with many operating systems (including most Linux distributions and Mac OS X), so , Just launch a terminal and type ‘vim’ to get started.

: why to use vim ?

With some learning, Vim can be more powerful than many graphical IDEs. As it certainly doesn’t eat hundreds of megs of memory just to view an empty file (like in, Eclipse).

Vim

The Basics

Some commands in this guide start with a colon: pressing it will display the command prompt where the subsequent command is written.

Commands written in CAPITAL LETTERS are specific keys: for example, ESC means the escape key on your keyboard.

Commands without a colon are more like hotkeys - they can be used in the Vim default mode (which is the mode Vim starts in).

All commands in Vim are case-sensitive.

EDITING TEXT

a) To start inserting text on the current cursor location:

1i

b) To start inserting at the end of the current line:

1A

c) To exit insert mode, and return to the default mode:

1ESC

EXITING VIM

a) To quit, discarding any changes you might have made (before press ESC):

1:q!

b) To quit, saving any changes you’ve made(before press ESC):

1:wq!

a) To move to line 285 (before press ESC):

1:285

b) To search for the word return(before press ESC):

1:return

CUT COPY PASTE

a) To copy the current selection into the buffer (think of it as a clipboard):

1y

b) To cut the current selection:

1d

c) To copy the current line into the buffer:

1yy

d) To copy 3 lines including the current line into the buffer:

13yy

e) To cut the current line and place it into the buffer:

1dd

f) To cut 5 lines including the current line:

15dd

UNDO AND REDO

a) To undo the last change:

1u

b) To redo the last change you just undid:

1CTRL + R

SYNTAX HIGHLIGHTING AND INDENTATION

a) Turn on syntax highlighting:

1:syntax on

b) Enable automatic indentation:

1:set autoindent

or

1:gg=G

WORKING WITH MULTIPLE FILES

a) To open new tab of terminal

1CTRL+SHIFT+T

b) To open server.py in a new tab:

1:tabe server.py

c) To move to the next tab on the right:

1:tabn

e) To move to the previous tab on the left:

1:tabp

SPLIT VIEW

a) To open templates/base.html in a vertical split screen:

1:vs templates/base.html

b) To open shared.js in a horizontal split screen:

1:sp shared.js

c) To move between split screens:

1CTRL + W + ARROW KEYS

More articles from Nancy Chauhan

Transmission of HDMI data streams to HDMI/DVI monitors via Spartan 6 FPGA

This project work aims to transmit High-Definition Multimedia Interface (HDMI) and Digital Visual Interface (DVI)

January 20th, 2019 · 4 min read

Running a JVM inside a container

Running the JVM in a container presented problems with memory and cpu sizing and usage that led to performance loss.

December 26th, 2018 · 1 min read
© 2018–2020 Nancy Chauhan
Link to $https://twitter.com/_nancychauhanLink to $https://github.com/Nancy-ChauhanLink to $https://www.linkedin.com/in/nancy-chauhan/Link to $https://www.instagram.com/_nancychauhan/Link to $https://medium.com/@_nancychauhan