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
Police Scanner Encryption Explained
10 Ways the NSA Is Spying on You Right Now | ExpressVPN Blog
Jack Doherty Lpsg
Craigslist Home Health Care Jobs
Where are the Best Boxing Gyms in the UK? - JD Sports
Hotels Near 625 Smith Avenue Nashville Tn 37203
80 For Brady Showtimes Near Marcus Point Cinema
Displays settings on Mac
Dityship
Ktbs Payroll Login
Tiger Island Hunting Club
LeBron James comes out on fire, scores first 16 points for Cavaliers in Game 2 vs. Pacers
Methodist Laborworkx
‘Accused: Guilty Or Innocent?’: A&E Delivering Up-Close Look At Lives Of Those Accused Of Brutal Crimes
Chris Hipkins Fue Juramentado Como El Nuevo Primer Ministro De...
Hijab Hookup Trendy
Jvid Rina Sauce
Kaomoji Border
Lake Nockamixon Fishing Report
Equibase | International Results
Officialmilarosee
Sizewise Stat Login
Lowes Undermount Kitchen Sinks
Apple Original Films and Skydance Animation’s highly anticipated “Luck” to premiere globally on Apple TV+ on Friday, August 5
Popular Chinese Restaurant in Rome Closing After 37 Years
Wbiw Weather Watchers
Egizi Funeral Home Turnersville Nj
2487872771
Hdmovie2 Sbs
Is Holly Warlick Married To Susan Patton
Kitchen Exhaust Cleaning Companies Clearwater
Yayo - RimWorld Wiki
Pokémon Unbound Starters
HP PARTSURFER - spare part search portal
Superhot Free Online Game Unblocked
Solo Player Level 2K23
UPC Code Lookup: Free UPC Code Lookup With Major Retailers
Broken Gphone X Tarkov
Most popular Indian web series of 2022 (so far) as per IMDb: Rocket Boys, Panchayat, Mai in top 10
拿到绿卡后一亩三分地
Property Skipper Bermuda
Pensacola Cars Craigslist
Urban Blight Crossword Clue
“To be able to” and “to be allowed to” – Ersatzformen von “can” | sofatutor.com
Grand Valley State University Library Hours
Quick Base Dcps
Holzer Athena Portal
Neil Young - Sugar Mountain (2008) - MusicMeter.nl
Unbiased Thrive Cat Food Review In 2024 - Cats.com
Jesus Calling Oct 6
Cognitive Function Test Potomac Falls
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.