VIM Cursor Movement & Edit Commands in MacOS (2024)

Note : Most vi commands are case sensitive. The same command typed in lowercase and uppercase characters might have different effects.

Move the cursor using combinations of the up, down, right, and left arrow keys.

a. Moving One Word

  • Press w (“word”) to move the cursor to the right one word at a time.
  • Press b (“back”) to move the cursor to the left one word at a time.
  • Press W or B to move the cursor past the adjacent punctuation to the next or previous blank space.
  • Press e (“end”) to move the cursor to the last character of the current word.

b. Moving to Start or End of Line

  • Press ^ to move the cursor to the start of the current line.
  • Press $ to move the cursor to the end of the current line.

c. Moving to the Top of file

  • Press H (“high”) to move the cursor to the top of the screen.

d. Moving to the Middle of file

  • Press M (“middle”) to move the cursor to the middle of the screen.

e. Moving to the Bottom of file

  • Press L (“low”) to move the cursor to the bottom of the screen.

vi provides many commands for inserting text. Each of these commands places vi in entry mode. To use any of these commands, you must first be in command mode. Remember to press Esc to make sure you are in command mode.

a. Append

  • Type a (append) to insert text to the right of the cursor.
  • Type A to add text to the end of a line.

b. Insert

  • Press i to insert text to the left of the cursor.
  • Press I to insert text at the beginning of a line.

c. Open Line

Use these commands to open new lines, either above or below the current cursor position.

  • Type o to open a line below the current cursor position.
  • Type O to open a line above the current cursor position.

Changing text involves the substitution of one section of text for another. vi has following ways to do this:

a. Changing a Word

  • Press cw to replace a word, followed by the new word. To finish, press Esc.

To change some part of a word, place the cursor on the word, to the right of the portion to be saved. Type cw, type the correction, and press Esc.

b. Changing a Line

  • Press cc to replace a line. The line disappears, leaving a blank line for your new text. Press Esc to finish.

c. Substituting Character(s)

  • Press s to substitute one or more characters for the character under the cursor, followed by the new text. Press Esc to return to command mode.

d. Replacing One Character

  • Press r to replace the character highlighted by the cursor with another character, followed by just one replacement character.

After the substitution, vi automatically returns to command mode (you do not need to press Esc).

When you edit text and make changes to a vi file, you might occasionally wish that you had not changed something. vi’s undo commands enable you to back up one operation and continue on from there.

a. Undoing the Previous Command

  • Press u to undo a change which you did previously.

b. Undoing Changes to a Line

  • Press U to undo all changes you’ve made to a line.

These vi commands delete the character, word, or line you indicate. vi stays in command mode, so any subsequent text insertions must be preceded by additional commands to enter entry mode.

a. Deleting One Character

  • Press x to delete one character where the cursor is presently.
  • Press X to delete one character before (to the left of) the cursor.

b. Deleting a Word or Part of a Word

  • Press dw to delete a word. The word and the space it occupied are removed.

To delete part of a word, position the cursor on the word to the right of the part to be saved. Type dw to delete the rest of the word.

c. Deleting a Line

  • Press dd to delete a line.

The methods for copying or moving small blocks of text in vi involves the use of a combination of the yank, delete, and put commands.

a. Copying Lines

  • Press yy or Y to copy the line. Note that Y does the same thing as yy.
  • Press p to paste the line below the cursor
  • Press P to paste the line above the cursor
  • Copy multiple lines using 5yy (where 5 indicates to copy 5 lines)

The yy command works well with a count: to yank 5 lines, for example, type 5yy. Five lines, counting down from the cursor, are yanked, and vi indicates this with a message at the bottom of the screen: 5 lines yanked.

You can also use the P or p commands immediately after any of the deletion commands discussed earlier. This action puts the text you deleted above or below the cursor, respectively.

b. Moving Lines

  • Press dd to cut the line. Note that Y does the same thing as yy.
  • Press p to paste the line below the cursor
  • Press P to paste the line above the cursor
  • Cut multiple lines using 5dd (where 5 indicates to cut 5 lines)
VIM Cursor Movement & Edit Commands in MacOS (2024)
Top Articles
Stock Market Crash: How To Protect 401k And IRA From Losing Money
How To Survive A Stock Market Crash
Ffxiv Act Plugin
Windcrest Little League Baseball
Wannaseemypixels
Mama's Kitchen Waynesboro Tennessee
Seething Storm 5E
Ecers-3 Cheat Sheet Free
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
South Ms Farm Trader
David Turner Evangelist Net Worth
No Hard Feelings Showtimes Near Cinemark At Harlingen
[Birthday Column] Celebrating Sarada's Birthday on 3/31! Looking Back on the Successor to the Uchiha Legacy Who Dreams of Becoming Hokage! | NARUTO OFFICIAL SITE (NARUTO & BORUTO)
Bj Alex Mangabuddy
List of all the Castle's Secret Stars - Super Mario 64 Guide - IGN
Vanessawest.tripod.com Bundy
TBM 910 | Turboprop Aircraft - DAHER TBM 960, TBM 910
Libinick
Persona 5 Royal Fusion Calculator (Fusion list with guide)
Amazing deals for Abercrombie & Fitch Co. on Goodshop!
Doublelist Paducah Ky
Ceramic tiles vs vitrified tiles: Which one should you choose? - Building And Interiors
Reviews over Supersaver - Opiness - Spreekt uit ervaring
2487872771
Margaret Shelton Jeopardy Age
Doctors of Optometry - Westchester Mall | Trusted Eye Doctors in White Plains, NY
Usa Massage Reviews
Gunsmoke Tv Series Wiki
Busch Gardens Wait Times
Missing 2023 Showtimes Near Grand Theatres - Bismarck
Pch Sunken Treasures
Nicole Wallace Mother Of Pearl Necklace
Ni Hao Kai Lan Rule 34
Unity Webgl Player Drift Hunters
Louisville Volleyball Team Leaks
Temu Y2K
Qlima© Petroleumofen Elektronischer Laserofen SRE 9046 TC mit 4,7 KW CO2 Wächter • EUR 425,95
Metro Pcs Forest City Iowa
All Obituaries | Sneath Strilchuk Funeral Services | Funeral Home Roblin Dauphin Ste Rose McCreary MB
Emily Tosta Butt
Nina Flowers
Bustednewspaper.com Rockbridge County Va
Squalicum Family Medicine
Gas Buddy Il
Lorton Transfer Station
Conan Exiles Colored Crystal
303-615-0055
9294027542
4Chan Zelda Totk
Sleep Outfitters Springhurst
Pilot Travel Center Portersville Photos
Latest Posts
Article information

Author: Tish Haag

Last Updated:

Views: 6367

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tish Haag

Birthday: 1999-11-18

Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

Phone: +4215847628708

Job: Internal Consulting Engineer

Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.