Text Editors
100%

Advanced Text-Fu · Lesson 2

Text Editors

Learn how to choose and configure a terminal text editor for Linux administration and development.

Linux configuration, scripts, source code, and logs are commonly stored as plain text. A terminal editor lets you work with those files in a local terminal, a remote SSH session, or an environment without a graphical desktop.

Choosing an Editor for the Environment

No single editor is best for every person or task. Graphical editors, terminal editors, and integrated development environments can all be appropriate. For command-line work, choose an editor that is installed, that you can exit safely, and whose basic editing model you understand.

Do not assume Vim or Emacs is installed. Check command resolution in the current shell:

$ command -v vim
/usr/bin/vim
$ command -v emacs
/usr/bin/emacs

An empty result with a nonzero status means that name was not found through the current command search. Minimal systems may provide vi, while others include Nano or no interactive editor at all.

Which command checks whether the current shell can resolve an executable named vim?

Understanding Vim's Model

Vim is a modal editor. The same key can have different meanings depending on the current mode:

  • Normal mode interprets keys as navigation and editing commands.
  • Insert mode inserts typed text.
  • Command-line mode accepts commands such as writing or quitting.

This model makes repeated keyboard editing efficient after practice, but new users must keep track of the active mode. Later lessons introduce Vim one operation at a time.

What does it mean that Vim is modal?

Understanding Emacs's Model

Emacs commonly uses key combinations and named commands within an extensible environment. Files are visited in buffers, and major and minor modes customize behavior for different content and tasks. Emacs can run in a terminal or a graphical frame.

Vim and Emacs both support far more than basic editing through configuration and extensions. Begin with opening, changing, saving, and closing a plain-text file before adding customization.

In Emacs terminology, where is a visited file's editable text normally held?

Setting a Preferred Editor

Many command-line programs consult VISUAL or EDITOR when they need to start an editor. For example, choose Vim for commands launched from the current Bash session and its children:

$ export VISUAL=vim
$ export EDITOR="$VISUAL"

These variables express a preference; they do not install the program. Use a command that actually exists, and place the exports in the appropriate shell startup file only after testing them.

What does export EDITOR=vim do?

Practicing without Risking Important Files

Learn on a disposable file in a directory you own:

$ printf 'first line\nsecond line\n' > editor-practice.txt
$ vim editor-practice.txt

Avoid beginning with system configuration or another user's data. Make a backup before changing an important file, understand how to save and exit, and review the result with a read-only command such as cat or diff.

What is the safest first file for practicing an unfamiliar editor?

To practice opening, editing, and saving terminal text files, try this hands-on lab:

  1. Edit Text Files in Linux with Vim and Nano - Practice creating files, editing text, saving files, and navigating with both vi/vim and nano, essential skills for any Linux user.

Lesson complete

You finished Text Editors

You can now choose a terminal editor and prepare a safe practice workflow.

  • Check whether an editor command is available.

  • Recognize Vim's modal interaction model.

  • Recognize Emacs buffers and extensible modes.

  • Set an editor preference without confusing it with installation.

  • Practice on disposable text before editing important files.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Next Lesson
Back to Advanced Text-Fu