A Quickstart Guide to Vim Text Editing

This tutorial will walk you through the basics of using vim, a powerful text editor available on Sherlock. Even if you’ve never used a command-line editor before, this guide will get you started. We’ll focus on the essential commands you need to create, edit, save and search files.

What is vim?

vim (Vi Improved) is a text editor that runs directly in your terminal. It might seem intimidating at first, but it’s incredibly powerful and efficient once you learn a few basic commands. It’s widely available on Linux/Unix systems like Sherlock. Why learn it? Because it’s ubiquitous, meaning you’ll find it (or a similar editor) on almost any system you encounter.

Prerequisites:

  • You must be logged into your Sherlock account via the terminal.
  • A basic understanding of navigating the command line (using cd to change directories, ls to list files) is helpful.

1. Opening a File:

Let’s start by opening a file. There are two common scenarios:

  • Opening an Existing File: If you have a file named my_script.txt in your current directory, you’d open it with:
    vim my_script.txt
    
  • Creating a New File: If you want to create a new file named new_file.txt, you’d also use vim:
    vim new_file.txt
    

If the file doesn’t exist, vim will create it when you save.

What you’ll see:

After running either of those commands, the terminal screen will change, and you’ll be in the vim editor. If the file exists, its content will be displayed. If it’s a new file, you’ll see a blank screen (mostly tildes ~ on the left).

Key Concept: Modes

vim operates in different modes. The most important modes for beginners are:

  • Normal Mode (Command Mode): This is the default mode. You use it to navigate the file, delete text, copy and paste, and execute commands. When you first open vim, you are in Normal Mode. You cannot type text directly into the file in this mode.
  • Insert Mode: In this mode, you can type text into the file just like in a regular text editor.
  • Visual Mode: In this mode, you can select the text to copy, delete, or operate on as blocks.

2. Entering Insert Mode (Adding/Editing Text):

To start typing, you need to switch to Insert Mode. Press the i key.

  • Press i (for insert). You should see -- INSERT -- at the bottom of the screen. Now you can type!

Type some text into the file. For example:

This is my first time using vim on Sherlock.
It's a bit different than a regular text editor.

3. Saving Your Changes:

To save your changes, you need to exit Insert Mode and enter Normal Mode.

  • Press Esc (Escape Key): This takes you back to Normal Mode. The – INSERT – indicator at the bottom will disappear.
  • Type :w (for write) and press Enter: This saves (writes) the file. You should see a message at the bottom of the screen indicating the file has been written (e.g., "new_file.txt" 2L, 84C written).

4. Exiting vim:

To exit vim, you also use Normal Mode.

  • Press Esc (Escape Key): Make sure you’re in Normal Mode.
  • Type :q (for quit) and press Enter: This quits vim.

Putting it together: Saving and Exiting

You can combine saving and quitting in one command:

  • Press Esc (Escape Key): Make sure you’re in Normal Mode.
  • Type :wq (for write and quit) and press Enter: This saves the file and exits vim.

5. Ignoring Changes and Exiting:

Sometimes, you might make changes you don’t want to keep. Here’s how to discard those changes and exit:

  • Press Esc (Escape Key): Make sure you’re in Normal Mode.
  • Type :q! (for quit, forcing the exit without saving) and press Enter: This discards any changes you made since the last save. Use this with caution!

6. Common Navigation Commands (in Normal Mode):

These commands help you move around the file without typing:

  • h: Move cursor left.
  • j: Move cursor down.
  • k: Move cursor up.
  • l: Move cursor right.
  • 0 (zero): Move to the beginning of the line.
  • $: Move to the end of the line.

7. Deleting Text (in Normal Mode):

  • x: Delete the character under the cursor.
  • dd: Delete the entire line.

8. Undoing Changes (in Normal Mode):

  • u: Undo the last change.

Example Workflow:

  1. Open a file: vim my_script.txt
  2. Enter Insert Mode: Press i
  3. Add or edit text.
  4. Exit Insert Mode: Press Esc
  5. Save the file: Type :w and press Enter
  6. Exit vim: Type :q and press Enter

Or, save and exit in one step: :wq and press Enter.

Further Learning:

This is just a basic introduction. vim has many more features. Here are some ways to learn more:

  • vimtutor: Type vimtutor at the command line. This opens an interactive tutorial within vim itself. It’s a great way to learn the basics.
  • Practice: The more you use vim, the more comfortable you’ll become.

A Quickstart Guide to Using Nano Text Editor

This tutorial will walk you through the basics of using nano, a powerful text editor available on Sherlock. Even if you’ve never used a command-line editor before, this guide will get you started. We’ll focus on the essential commands you need to create, edit, save and search files.

What is Nano?

nano is a simple, user-friendly text editor that runs in your terminal. It’s ideal for making quick edits to configuration files, writing scripts, or creating new text files directly on Sherlock. Unlike some more advanced editors like vim or emacs, nano is designed to be easy to learn and use.

Prerequisites:

  • You must be logged into your Sherlock account via the terminal.
  • A basic understanding of navigating the command line (using cd to change directories, ls to list files) is helpful.

1. Opening a File

To open a file with nano, use the following command:

nano my_script.sh
  • If the file exists: nano will open the existing file for editing.
  • If the file doesn’t exist: nano will open a new, empty file with that name. It will be created when you save the file.

2. The Nano Interface

When you open a file with nano, you’ll see a screen that looks something like this:

GNU nano 2.9.8                                   my_script.sh

#!/bin/bash
# This is a simple script.
echo "Hello, Sherlock!"

                                         [ New File ]
^G Get Help  ^O Write Out ^W Where Is  ^K Cut Text  ^J Justify   ^X Exit
^R Read File ^\ Replace  ^Y Prev Page ^C Cur Pos   ^U UnCut Text^T To Spell

Let’s break down the key parts:

  • Top Line: Shows the nano version, the filename you’re editing, and whether the file has been modified. If it says [ Modified ], it means you’ve made changes that haven’t been saved yet.
  • Main Area: This is where you see and edit the contents of your file.
  • Bottom Two Lines (Command Shortcuts): These lines show you the most common commands you can use in nano. Each command is indicated by a caret (^) followed by a letter. The caret means you need to press the Ctrl key and the letter at the same time.

  • For example, ^X Exit means “Press Ctrl + X to exit nano.”
  • ^G Get Help means “Press Ctrl + G to get help.”

3. Editing Text

Editing text in nano is very straightforward:

  • Type: Simply type the text you want to add.
  • Move the Cursor: Use the arrow keys (up, down, left, right) to move the cursor around the file. You can also use the Page Up and Page Down keys to scroll through the file.
  • Delete Text: Use the Backspace key to delete characters to the left of the cursor, and the Delete key (if you have one) to delete characters to the right of the cursor.

    Insert New Lines: Press the Enter key to insert a new line.

4. Saving Your Changes

To save the changes you’ve made to the file:

  1. Press Ctrl + O (Write Out). This means hold down the Ctrl key and press the O key.
  2. nano will prompt you for the filename to save to. By default, it will suggest the name of the file you opened. If you’re happy with the name, just press Enter.
  3. nano will save the file and display a message indicating the number of lines written.

5. Exiting Nano

To exit nano:

  1. Press Ctrl + X (Exit).
  2. If you’ve made changes that haven’t been saved, nano will ask you if you want to save them.
    • Press Y to save the changes. It will then prompt you for a filename. Press Enter to accept the default filename.
    • Press N to discard the changes (the file will remain unchanged).
    • Press Ctrl + C to cancel the exit and return to editing.

6. Ignoring File Changes (Discarding Edits)

If you’ve made changes you don’t want to keep, simply exit nano ( Ctrl + X) and answer N (No) when prompted to save the chan ges.

7. Navigating the Text

  • Arrow Keys: As mentioned before, the arrow keys are the primary way to move around the text.
  • Page Up/Page Down: These keys scroll through the file one page at a time.
  • Ctrl + A: Move to the beginning of the current line.
  • Ctrl + E: Move to the end of the current line.
  • Ctrl + Y: Move to the previous page.
  • Ctrl + V: Move to the next page.

8. Searching Within the Text

To search for a specific word or phrase within the file:

  1. Press Ctrl + W (Where Is).
  2. nano will prompt you to enter the search term. Type the text you’re looking for and press Enter.
  3. nano will jump to the first occurrence of the search term in the file.
  4. To find the next occurrence, press Alt + W (hold down the Alt key and press W). You may need to use the Esc key followed by the W key depending on the keyboard configuration.

Further Learning:

Nano is relatively simple, but here are some ways to learn more:

  • Built-in Help: The easiest way to get help is within nano itself. Press Ctrl + G (Get Help) to access the built-in help documentation. This provides a detailed explanation of all the commands and options available in nano. The help file is navigable within nano itself so use the arrow keys or page up and page down keys.
  • Manual Page (Man Page): You can access the full manual page for nano from the command line using the man command:
    man nano
    

    This will display the complete documentation for nano. Use the arrow keys to navigate the page and press q to quit.

  • Practice is Key: The best way to learn nano is to use it. Create a test file, practice editing it, saving it, and searching within it. Don’t be afraid to experiment – you can always discard changes if you make a mistake.

Copyright CEMC 2026. This site is built and maintained by William Arnold.

This site uses Just the Docs, a documentation theme for Jekyll.