UNIX Editors

Text Editor: Program that lets you create and test in a computer file.

Standard text editors available on most UNIX systems:

Popular editors available on most UNIX platforms:

History: vi

History/Overview: vim

vim: “Vi Improved” (originally “Vi Imitation”)

Extended (from vi) features:

History/Overview: emacs

EMACS (Editor MACroS): Family of text editors characterized by their extensibility.

Note: Emacs and vi are the two main contenders in the editor wars of UNIX culture.

vi/vim: The Standard Editor

vi supplies command for:

vi uses a buffer. Edited files exist in a temporary buffer in memory, which you can write to a new or existing file, or not write at all.

vi operates in different modes, which can be entered in various ways:

  1. Command Mode:
  2. Insert Mode:

Example: Opening/creating a file for editing

vi filename
Diagram demonstrating Vim movement commands Source: @LevelbossMike/vim_shortcut_wallpaper

Note: The power of Vim is when motions become natural (like touch-typing), allowing you to create and use Vim motions without much thought or memorization. It’s a steep learning curve, but you don’t have to learn everything to become a fast typist.

Basic Movement:

Basic Commands:

Note: There are lots of commands that start with g or z that you might come across. However, g and z aren’t actually a basic command like x or p, they’re just a prefix because there are only so many keys on the keyboard.

Search:

Basic Vim Motions: {OPERATOR}{COUNT}{MOTION}

Text Object Vim Motions: {OPERATOR}{A|I}{TEXT-OBJECT}

Learning Vim:

  1. Built-in :vimtutor.
  2. Cheat sheets, videos, etc.
  3. Practice.

Special Marks (advanced, but helpfiul):

CommandDescription
'.jump to position where last change occurred in current buffer
'"jump to position where last exited current buffer
'0jump to position in last file edited (when exited Vim)
'1like '0 but the previous file (also '2 etc)
''jump back (to line in current buffer where jumped from)
''jump back (to position in current buffer where jumped from)
'[ / ']jump to beginning/end of previously changed or yanked text
'< / '>jump to beginning/end of last visual selection

Resource Configuration File: The resource configuration file for vi is ~/.exrc

Emacs

Example: Opening/creating a file for editing

emacs filename

Modes in Emacs

Modes are the methods by which Emacs features are expressed in the context of specific types of content.

Two types of modes:

  1. Major:
  2. Minor:

Emacs Configuration

Emacs uses Emacs Lisp for configuration (and other things).

Basic Commands

Basic Commands:

Basic Movement Commands:

Basic Editing Commands:

Important and Useful Commands:

Help Commands:

Search/Replace Commands:

Search/Replace with Regex (Regular Expressions):

Regex Characters:

More Commands

Note: These commands probably won’t come up in any exams, so I’m separating them for the sake of organization, but keeping them for posterity.

Window Splitting and Movement Commands:

Shell Commands:

Programming Commands:

Programming Commands: C, C++ and Java Modes:

Programming Commands: More General

Programming Commands: GDB

Macro Commands:

Text Commands:

Bookmark Commands: