Vim and Vim Tutor

Goal: Introduce Vim and how and why to use the vimtutor as a guided tool to learn how to use this text editor.


Note:

  • On our MedicineBow cluster, vi is an alias for vim – meaning if you start vi, vim will start.



Vim: Core Concepts

  • Since we are using a text editor from the command-line and only using the keyboard, we do not have any form of GUI or drop down menus.

  • Vim uses the concept of modes, which you switch between, to allow you to type/edit the contents of a file, and then to perform commands such as move to end of a line, delete a line, write/save the file, quit/exit the editor.


Open, Insert, Write, Quit a File

This section will take you through the basics of opening a file, switching modes, entering some text, and then writing (saving) our file, and then quitting (exiting) the editor.

image-20240905-164326.png
image-20240905-164430.png

Vim Tutor

[]$ vimtutor =============================================================================== = W e l c o m e t o t h e V I M T u t o r - Version 1.7 = =============================================================================== Vim is a very powerful editor that has many commands, too many to explain in a tutor such as this. This tutor is designed to describe enough of the commands that you will be able to easily use Vim as an all-purpose editor. ...

Vimtutor: Lesson 1: Cursor Exit Delete Insert Append

Lesson 1.1: MOVING THE CURSOR Lesson 1.2: EXITING VIM Lesson 1.3: TEXT EDITING - DELETION Lesson 1.4: TEXT EDITING - INSERTION Lesson 1.5: TEXT EDITING - APPENDING Lesson 1.6: EDITING A FILE

Summary

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 1 SUMMARY 1. The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right) 2. To start Vim from the shell prompt type: vim FILENAME <ENTER> 3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes. OR type: <ESC> :wq <ENTER> to save the changes. 4. To delete the character at the cursor type: x 5. To insert or append text type: i type inserted text <ESC> insert before the cursor A type appended text <ESC> append after the line NOTE: Pressing <ESC> will place you in Normal mode or will cancel an unwanted and partially completed command. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Vimtutor: Lesson 2: Delete Move


Summary:


Vimtutor: Lesson 3: Put Replace


Summary


Vimtutor: Lesson 4: Search


Summary


Vimtutor: Lessons Continue…