Live Chat Software by Kayako
Become a Vi Master by Learning These 30+ Key Bindings
Posted by Thang Le Toan on 16 September 2016 01:33 AM


Vi is a powerful text editor included on most Linux systems. Many people swear by vi and find it faster than any other editor once they’ve learned its key bindings. You can even use vi key bindings in Bash.

We’ve already covered getting started with vi for beginners. If you haven’t used vi in a while, you might want to give that post a look to get a refresher on the basics.

Mode Switching

As a short recap, vi is a modal editor – there’s an insert mode and a standard command mode. In insert mode, vi functions similar to a normal text editor. In command mode, you take advantage of these key bindings.

  • i – Enter insert mode.
  • Escape – Leave insert mode. If you’re already in command mode, Escape does nothing, so you can press Escape to ensure you’re in command mode.


Moving the Cursor

Vi uses the hjkl keys to move the cursor in command mode. Early computer systems didn’t always have arrow keys, so these keys were used instead. One advantage of these keyboard shortcuts is that you don’t have to move your fingers from the home row to use them.

  • h – Move cursor left.
  • j – Move cursor down.
  • k – Move cursor up.
  • l – Move cursor right.

You can also use search commands to quickly move the cursor.

  • / – Type a / followed by some text you want to find and press Enter to quickly move your cursor to the location of the text in the file. For example, if you have the word iguana in your file, type /iguana and press Enter to quickly move the cursor there.
  • ? – Like /, but searches backwards.
  • f – Type an f followed by any character to quickly move the cursor to the next occurrence of the character on the current line. For example, if you have the line “Hello world” on a line and your cursor is at the beginning of the line, type fo to move to the o in Hello. Type fo again to move to the o in world.
  • F – Like f, but searches backwards.
  • % – Jump between the nearest (), [], or {} characters on the line.

Use these commands to quickly move to locations in the file:

  • H – Move cursor to highest (top) line in file.
  • M – Move cursor to middle line in file.
  • L – Move cursor to lowest (bottom) line in file.
  • #G – Type a number and then type G to go to that line in the file. For example, type 4G and press Enter to move to the fourth line in the file.

Moving between words:

  • w – Move forward a word.
  • #w – Move forward a number of words. For example, 2w moves forward two words.
  • b – Move back a word.
  • #b – Move back a number of words. For example, 3b moves back three words.
  • e – Move to end of the current word.


Copying & Pasting

Vi refers to the act of copying as “yanking.”

  • v – Press v and move the cursor to select a section of text.
  • y – Copy (yank) the selected text.
  • p – Paste at cursor.
  • x – Cuts the selected text. Cuts the character under the cursor if no text is selected
  • r – Type r and then type another character to replace the character under the cursor.

Combining Commands

Some commands – including the y and v commands above and the d (delete) command accept cursor motion commands.

For example, when you press d to delete some text, nothing will happen until you enter a cursor motion command. For example:

  • dw – Deletes the next word.
  • db – Deletes the previous word
  • de – Deletes to the end of the current word.
  • dL – Deletes all text below the cursor in the file.
  • d/unicorn – After pressing Enter, deletes all text between the cursor and the word “unicorn” in the current file.
  • dd – Deletes an entire line.

As you can see, the combination of combining a command with a cursor movement command is very powerful.


Repeat & Undo

Vi’s repeat command is very powerful, as it can repeat complex, combined commands.

  • u – Undo.
  • . – The . repeats the last full command.  The insert command also functions as a command here. For example, type iunicorn and press Escape. You can then use the . key to insert the word unicorn at the cursor.

Bonus: Using Vi Key Bindings in Bash

Once you’ve mastered the vi key bindings, you may want to use them elsewhere on your system. No problem – you can set the Bash shell to use vi-style key bindings.

Try this out in the current session by running the following command in a Bash terminal:

set -o vi

Bash will start in insert mode – press Escape to enter command mode and use these key bindings.

If you like this, you can add the command to your ~/.bashrc file and it will be automatically run each time you log in. Use the vi .bashrc command to open and edit the file in vi.


This isn’t a complete list of key bindings for vi, but it should help you flex your vi wings and learn to fly. This list of key bindings at Harvard’s website is more complete and has more information, although it’s less organized and harder to digest all at once.

(0 vote(s))
Not helpful

Comments (2)
27 December 2019 11:58 AM
fitness tøj til kvinder køb fitnesstøj til kvinder fra carite <a href="">trænings t shirt hvid</a> billi bi sko hos pricerunner se den <a href="">annika korte støvler</a> superfit boys sutsko bully denim <a href="">hummel maroon softshell dragt</a> pigers sko athletic inspired converse chuck taylor party <a href="">nike pro zonal strength tights herre</a>
kurt geiger emma big black leather tote bag kurt geiger fashion <a href="">disney carry the magic designer style tote bag</a> chanel designer handbags foto 17 chanel designer handbags foto 18 <a href="">michael kors fashion personality zip rivet backpack mk women d</a> buy fendi online fendi monster convertible baguette w tags handbags <a href="">eume lexus 22 ltr laptop backpack for 15.6 inch laptop and nylon water resistance backpack black bags</a> lacoste chantaco small crossover bag in black lyst <a href="">texas school district random</a>
rosita shorts shorts grøn pulz jeans <a href="">sport og sex har givet jbs opmærksomhed</a> 430 waterproof softshell pink <a href="">weekend med barnedåb og hygge copenhagen kiddo</a> billi bi archives dresscodes <a href="">ray ban solbriller aviator großhandel</a> brune bugatti sko dame nye sko på nett hos <a href="">boxershorts 3 pack trunks print</a>

navy kjole med blade by angele <a href=>cykelhandler i vejle med stor erfaring</a> inkontinens badebukser til drenge <a href=>bisgaard gummistøvler rosa m. blomster</a> dykkerbriller til børn arena køb og salg af nyt <a href=>torvegade med butikker vejle stenders vejle no 133 k 7100</a> rieker sko tysk kvalitet til ham og hende <a href=>en fant sko grå m. velcro find billig pris</a>
louis vuitton brown monogram denim trapeze handle bag <a href=>heavy duty school bag cosmus norwitch blue 33l waterproof backpacks bag with laptop compartment price in india</a> termurah travel bag koper tas kanvas mickey minnie hitam pink ukuran besar harga penawaran hanya <a href=>happy sammies backpack s samsonite</a> cache coeur ventebadedragt sort <a href=>pæne støvler og hverdags vinterstøvler grenaa</a> 2 akslet gardin til sj. fragt lastbilmagasinet <a href=>lidt afslapning paa alt om ferie i kroatien</a>
tøysko sjekk ut converse nye kolleksjon kk <a href=>disruptor ii infant only at jd</a> carhartt sid pant blå chinos <a href=>g star i center fields herretøj københavn s</a> kjoler til fest mange lækre billige kjoler <a href=>hummel daisy jakke dark navy 104 cm</a> natalia blonde bluse brun <a href=>køb billige ray ban wayfarer rb2140 solbriller hvid ramme</a>

læs tøj online branchebladet tøj skibukser til børn spar 20 70 på attraktive mærker hummel jakke classic bee zip blå børn mirage essentials bikini bh
ray ban briller kvinder lola ramona sko blå med prikker ava walk on vender tilbage til profil optik avatar kostume til børn og voksne kostumeuniverset
dior m0579 supple lady dior bag in studded calfskin red chanel lambskin resin small drawstring bag black apricot red cruise 2017 michael kors skorpios purse shoulder bag orange brown braided rolled handle christian dior vintage double saddle bag diorissimo canvas
26 February 2020 12:11 AM
πουλόβερ γυναικείο με λαιμόκοψη v garcia jeans <a href="">προϊόντα για τα μαλλιά</a> base fashion ψηλομεσο skinny τζιν παντελονι <a href="">φόρεμα πουκάμισο με φλαμίνγκο μαύρο</a> βαμβακερή εκρού πετσέτα μονόγραμμα l <a href="">art καρέκλα polycarbonate pc διάφανο</a> θηκη skin body glove για iphone 3g 3gs black <a href="">zakcret παπουτσια μπασκετ</a>
doog soulder bag green <a href="">long read crafting culture and commerce at burberry</a> adidas bp classic adicolour tribe yellow <a href="">givenchy infinity medium chain hobo bag dark blue women handbags bags</a> adidas handbags blue and red adidas gym bag small duffel bag <a href="">childrens gym bags uk</a> 10 best smart backpacks with charger 2018 <a href="">details about mens travel duffle weekend overnight bag waterproof vintage canvas genuine</a>
sportkläder korta tights newline <a href="">angels tears diamonds diamantringar lösa diamanter</a> small foot indiantält tepee deluxe <a href="">cgb loft ljus rosa låda handtag</a> köp rimligt pris jenny känga stövletter kängor grå dam <a href="">lågt pris dam korta halsband brons silver vänskap friendship</a> soft grey damkläder jackor kappor svart jeansjacka <a href="">new balance item m vit blå new balance barn</a>

puma pro training ii medium bag gym bag red best price in india <a href=>coach yellow handbag for sale bags wallets for sale in</a> mb greene designer vertical essential 2 piece travel bag toiletry timely buys <a href=>football big net ball basketball bag buy at factory price club</a> make today amazing adult <a href=>new adidas nmd r1 lv logo black white adidas terrex boost indonesia</a> best school backpacks reviews 2015 <a href=>nwt coach minetta floral pink and white bag</a>
längd syrafast a4 <a href=>active mode på nätet utlopps kamouflage o nack</a> solkräm med betakaroten <a href=>kort ärmlös cut out klänning xl snör</a> färgläggningbok för barn <a href=>sommarklänning med lång ärm</a> nu vill jag göra något riktigt kul bröllopsfotograf skåne <a href=>beyonce hittar inte kläder som passar hennes rumpa aftonbladet</a>
γυναικεία παπούτσια μποτάκια <a href=>shop shop patras κατάστημα γυναικείων ρούχων πάτρα</a> παιχνιδια στο σπιτι για παιδια 3 ετων <a href=>η διατροφή των αρχαίων ελλήνων</a> ανδρικό μαγιό khos γαλάζιο <a href=>αντίδραση της επεγε στη διαφήμιση για ενδοσκοπήσεις σε</a> oxette κολιέ 01x27 γούρι 2019 από ροζ χρυσό ανοξείδωτο ατσάλι <a href=>μπουφάν αδιάβροχο με λουλούδια</a>

kvinnors parajumpers dodie vest grön junya watanabe kläder herr the north face 2016 svart fleece m canyonlands guldpläterade örhängen kvinnotecken faith militärjacka göteborg army gross
6 ιδέες για οικονομική ανακαίνιση σπιτιού τρία χρόνια φοράει κορσέ αυτή η 24χρονη αλλά η δακτυλίδι σακιδια πλατησ πεζοποριασ service παππας μαρκας
italy lyst michael michael kors extra small ava leather crossbody bag in white givenchy antigona smooth calfskin medium bag brand new polo bag herschel mens tour small bum bag black
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Kayako