Understanding Ex Commands
AS
Aman Saurav
4 min read
#history
#commands
“Ex commands” are those you type starting with a colon (:). They are called “Ex” because they originate from the Ex editor, the line-based predecessor to Vi (Visual) editor.
Why do we still use them?
Vim is essentially a visual mode running on top of Ex. When you enter Command-line mode (:), you are technically dropping down to the underlying line editor.
Common Ex Commands
:w(Write/Save):q(Quit):r filename(Read/Insert file content below cursor):!command(Shell command execution):s(Substitute)
Batch Processing
You can actually run Vim in “Ex mode” (vim -e) to process files non-interactively using scripts, making it a powerful stream editor alternative to sed.
# Example: Run a script of Ex commands on a file
vim -e input.txt < commands.vim