Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

VI/Vim Command Reference for DevOps Engineers: Modes, Search, Replace, Files, and Shell

This guide is for DevOps engineers who edit configuration, scripts, and manifests directly on remote systems. It gives you a practical VI/Vim command reference organized by real tasks, so you can move faster in terminal-only environments.

Originally published on 2009-04-06; fully revised and updated.

VI and Vim editor commands cheat sheet

Quick terminal tip: exporting a man page to a text file

The original post mentions man ls | col -b > .... In practice, provide an output filename. This writes a plain-text version of the man page (without backspace formatting characters):

man ls | col -b > ls-manpage.txt

How Vim editing typically flows

Vim is modal. Most production editing follows a repeatable cycle: open, navigate, edit, search/replace, save, and quit.

  • Normal mode: navigation and commands
  • Insert mode: typing text
  • Command-line mode: commands like :w, :q, and substitutions
  • Visual mode: selecting text ranges
flowchart TD
    A[Open file in Vim] --> B[Navigate in normal mode]
    B --> C[Search or jump to target]
    C --> D[Enter insert mode and edit]
    D --> E[Run substitute or format commands]
    E --> F{Need shell command}
    F -- yes --> G[Run :!cmd or :sh]
    G --> H[Return to Vim]
    H --> I[Write file]
    F -- no --> I[Write file]
    I --> J[Quit editor]

Save and quit commands compared

TaskCommandWhen to use
Quit (only if no unsaved changes):qSafe exit when buffer is clean
Force quit without saving:q! or ZQDiscard local edits
Write and quit:wq or ZZStandard save-and-exit flow
Write to another file and exit:wq {file}Save as a new path, then leave
Write selected range and quit:[range]wqPartial write workflows

Essential Vim commands by task

Open, read, and write files

:e filename
:e!
:w
:w newfile
:1,10 w outfile
:1,10 w >> outfile
:r infile
:23r infile
gfCode language: CSS (css)

Insert and edit text

a
A
i
I
o
O

Ctrl+a
Ctrl+x

Search patterns

/word
?word
/jo[ha]n
/\<fred\>
/\d\{4}
/^\n\{3}
:bufdo /searchstr/Code language: HTML, XML (xml)

Replace and bulk edits

:%s/old/new/g
:%s/old/new/gc
:2,35s/old/new/g
:5,$s/old/new/g
:%s/^/hello/g
:%s/$/Harry/g
:%s/ *$//g
:g/string/d
:v/string/d
:%s/\r//gCode language: JavaScript (javascript)

Buffers, splits, tabs, and explorer

:ls
:b 2
:e .
:Sex
:split filename
:vsplit filename
:hide
:only

:tabnew
gt
:tabfirst
:tablast
:tabm 2
:tabdo %s/foo/bar/g
:tab ball

:args
:args *.php
:grep expression *.php

Run Unix commands from inside Vim

:!pwd
:!ls
!!pwd
:r !date
:sh
exitCode language: CSS (css)

Useful options and syntax settings

:set all
:set
:set ai
:set noai
:set nu
:set nonu
:set list
:set nolist
:set showmode
:set noshowmode
:set ts=4
:set ic
:set noic
:set smartcase
:set autoindent
:set smartindent
:set shiftwidth=4
:syntax on
:syntax off
:set syntax=perlCode language: JavaScript (javascript)

Best practices and common pitfalls

  • Use :set nu and :set list when editing YAML, Makefiles, or whitespace-sensitive files.
  • Prefer :%s/.../.../gc over blind global replacement for production config changes.
  • Remember that some commands are Vim-specific (tabs, netrw explorer) and may not exist in minimal vi.
  • When you run shell commands via :! or :sh, verify your working directory and environment before writing changes.
  • If you suspect external file changes, reload with :e! before continuing edits.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

devenv.exe Command-Line Switches: Build, Run, Deploy, and Troubleshooting Reference

A practical reference to commonly used devenv.exe switches, including build, clean, deploy, run, and recovery flags. It also shows switch dependencies and realistic command patterns for automation.

Read More

Integrated Development Environments (IDEs)

Hey there, friend! Are you tired of constantly switching between different software tools just to write a simple program? Do you wish there was a better way…

Read More

Best & Most Popular Code Editor for Delphi programming Language

Understanding the Delphi IDE The idea of combining the editing, compiling, and managing of project files within one integrated programming application started way back in the 1970s,…

Read More

Best & Most Popular 5 Code Editors for Python programming

History of Python Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. Python consistently ranks as one of the…

Read More

Best & Most Popular 5 Code Editors for HTML/CSS programming

What is Code Editor ? Code Editor is one of the essential tools for programmers, designers, and even writers. Integrated Development Environments (IDEs) are often cumbersome for…

Read More

Top 5 free Software for Animation Making in 2019

1.     Blender Blender is a 3D software and it is free. You can make an animation film inside Blender. Also, 3D export of any other animation software…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Jason Mitchell
Jason Mitchell
3 months ago

In production environments, the biggest challenge with command-line editors is not learning shortcuts but preventing configuration drift. Engineers often make quick changes during incidents, and those temporary fixes can remain unnoticed and create future problems. A good practice is to capture emergency changes, review them later, and move validated updates into version-controlled configuration management. This approach keeps the speed advantage of tools like Vim while ensuring systems remain reproducible and easier to troubleshoot over time.

1
0
Would love your thoughts, please comment.x
()
x