Text editor

Also known as: code editor

On this page 7

A text editor is a program that creates and modifies plain-text files, storing exactly the characters the user types with no hidden formatting. In programming, it is the most basic of all development tools: source code, configuration files, build scripts, Markdown documentation and commit messages are all plain text, so every developer spends a large part of the working day inside one. When it is optimized for source code, the program is often called a code editor.

Unlike a word processor, which saves fonts, layout and embedded objects in a binary or XML container, a text editor writes a byte sequence in a defined character encoding, usually UTF-8. That simplicity is what makes text files readable by compilers, interpreters, version control systems and other tools.

How a text editor manages a file

A text editor loads a file into an in-memory buffer, lets the user change that buffer, and writes it back to disk only when the user saves. The buffer is usually not a single string: editors use data structures such as a gap buffer, a piece table or a rope so that inserting a character in the middle of a large file does not require copying the whole file.

Around the buffer, the editor renders text on screen, tracks one or more cursors and selections, keeps an undo history and interprets keyboard input. Encoding and line-ending handling are also its responsibility, and mistakes here cause some of the most frustrating bugs in software teams.

The table lists the file properties a careful editor must preserve or let the user control.

PropertyCommon valuesWhat goes wrong if mishandled
Character encodingUTF-8, UTF-16, Windows-1252Garbled accented characters
Line endingsLF on Unix, CRLF on WindowsNoisy diffs, failing shell scripts
Byte order markPresent or absentParser errors at the first byte
IndentationTabs or 2 or 4 spacesBroken Python or YAML structure
Final newlinePresent or absentSpurious changes in version control
File properties controlled by a text editor

Many projects record these preferences in an EditorConfig file at the repository root, which most modern editors read automatically so that every contributor saves files the same way.

Types of text editors

Text editors range from minimal terminal tools to extensible environments that approach a full IDE. The categories below overlap, but they describe how developers usually choose.

CategoryExamplesStrengthsTrade-offs
Basic editorsNotepad, nano, TextEdit in plain modeInstant start, nothing to learnNo syntax awareness
Modal editorsVim, Neovim, viFast keyboard editing, available on serversSteep learning curve
Extensible editorsEmacsProgrammable in Lisp, vast package libraryConfiguration effort
Graphical code editorsVisual Studio Code, Sublime Text, Notepad++Rich extensions, approachable interfaceHigher memory use for some
Web-based editorsBrowser editors in code hosting platformsNo installation, quick fixesLimited offline use
Main categories of text editors

The modal model deserves a note: in Vim, the same keys move the cursor in normal mode and insert text in insert mode. This design lets experienced users compose commands such as deleting three words with a few keystrokes, which is why vi or Vim is installed on almost every Unix server and remains essential for remote administration.

Features that make a text editor a code editor

A code editor adds language awareness on top of plain editing. The baseline features are syntax highlighting, automatic indentation, bracket matching, code folding, multi-cursor editing and search with regular expressions.

Deeper intelligence now comes from the Language Server Protocol (LSP), an open protocol in which a separate language server analyzes the code and the editor merely displays the results. One server for a language can therefore serve Vim, Emacs and Visual Studio Code alike, providing autocompletion, go-to-definition, rename refactoring and inline diagnostics. Syntax parsing has similarly moved toward incremental parsers such as Tree-sitter, which rebuild only the changed part of the syntax tree on every keystroke.

Editors also integrate with neighboring development tools. A linter and a code formatter can run on save, Git status appears in the margin, and a debugger adapter can be attached through the related Debug Adapter Protocol.

Text editor versus IDE and word processor

The boundary between a text editor and an IDE is a matter of scope, not of a single feature. An IDE bundles a project model, build system, debugger, profiler and refactoring engine for specific languages, whereas a text editor stays language-agnostic and gains capabilities through plugins.

AspectText editorIDEWord processor
Saved formatPlain textPlain text plus project metadataFormatted document
Language scopeAny, via pluginsDeep support for a fewNatural language
Startup and memoryLight to moderateHeavierModerate
Built-in build and debugOptional extensionsIntegratedNone
Suitable for source codeYesYesNo
How a text editor differs from related tools

In practice the categories have converged. Visual Studio Code is formally a code editor, yet with extensions it behaves much like an IDE, while IntelliJ IDEA offers a lightweight mode for quick file edits. The key test remains whether the tool writes exact plain text and whether language intelligence is built in or added.

Choosing and configuring a text editor

The right text editor depends on where you edit, what languages you use and how much configuration you accept. The decision table summarizes common situations.

SituationRecommended choiceReason
Editing config over SSHnano or VimPreinstalled, runs in any terminal
Polyglot web developmentGraphical code editor with LSPBroad extension ecosystem
Large Java or C# codebaseDedicated IDEDeep refactoring and indexing
Very large log filesEditor with streaming supportAvoids loading gigabytes into memory
Highly customized workflowEmacs or NeovimFully scriptable behavior
Selecting a text editor by situation

Common mistakes include editing code in a word processor that inserts smart quotes, saving scripts with CRLF line endings that break Unix shells, and installing dozens of unvetted extensions. Extensions run with the user’s privileges, so only trusted, maintained plugins should be installed, especially on machines that hold production credentials.

The simple explanation

A text editor is like a plain notebook for computers. It stores only the letters, numbers and symbols you type, with no bold, colors or page layout saved inside the file.

Programmers need exactly that, because computers read code exactly as written. A code editor helps by coloring different parts of the code, spotting typos and suggesting the next word, but the file it saves stays simple text that any other program can read.

How it is used in practice

A backend developer at a mid-sized online retailer starts the day in a graphical code editor with the Python language server, a formatter and Git integration enabled. While fixing a pricing bug, the editor flags an undefined variable before the code ever runs, and the formatter normalizes indentation to 4 spaces when the file is saved.

Later, a production server reports a misconfigured web proxy. The developer connects over SSH, opens the configuration file in Vim, corrects one directive and reloads the service within two minutes. Because the repository includes an EditorConfig file enforcing UTF-8 and LF line endings, the matching change committed afterward produces a clean one-line diff that a colleague reviews quickly.