blog
  • Blogs
    • Medium Articles
      • Linux
        • 40 Powerful Linux Networking Commands You Must Know.
        • These (Linux) VI Editor Shortcuts You Must Know
        • Bash/Linux Interview Questions for DevOps Engineers
        • Page 1
      • Git
        • 40 Powerful Git Commands Every Developer Should Know
        • 10 Git Best Practices That Every Developer Must Know
      • DevOps/SRE Interview Questions and Answers
        • Top DevOps/SRE Interview Questions and Answers on AWS VPC
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Terraform Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Kubernetes Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Dockerfiles
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Grafana
      • Installation
        • Docker Installation on Ubuntu 20/22
        • Install WireGuard VPN on Docker Compose
        • Install Redis on Docker Compose
        • Gravitee Docker Compose
      • Kubernetes Series 2025
        • Understanding Kubernetes: Part 1 -Control Plane
        • Understanding Kubernetes: Part 2 -Worker Node
        • Understanding Kubernetes: Part 3 -Pod
        • Understanding Kubernetes: Part 4-ReplicaSets
        • Understanding Kubernetes: Part 5 -Deployment
        • Understanding Kubernetes: Part 6 -DaemonSets
        • Understanding Kubernetes: Part 7 -StatefulSet
        • Understanding Kubernetes: Part 8 -ConfigMap
        • Understanding Kubernetes: Part 9 -Kubernetes Secret
        • Understanding Kubernetes: Part 10 -StorageClass
        • Understanding Kubernetes: Part 11 -Persistent Volume (PV)
        • Understanding Kubernetes: Part 12 -Persistent Volume Claim (PVC)
        • Understanding Kubernetes: Part 13 -Services
        • Understanding Kubernetes: Part 14 -ClusterIP Service
        • Understanding Kubernetes: Part 15 -NodePort Service
        • Understanding Kubernetes: Part 16 -Load Balancer Service
        • Understanding Kubernetes: Part 17 -Ingress
        • Understanding Kubernetes: Part 18 -Ingress Controller
        • Understanding Kubernetes: Part 19 -Headless Service
        • Understanding Kubernetes: Part 20-Network Policy
        • Understanding Kubernetes: Part 21 -CNI
        • Understanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits
        • Understanding Kubernetes: Part 23 Node Selector
        • Understanding Kubernetes: Part 24 Taints and Tolerations
        • Understanding Kubernetes: Part 25 Affinity and Anti-Affinity
        • Understanding Kubernetes: Part 26 Preemption and Priority
        • Understanding Kubernetes: Part 27 Role and RoleBinding
        • Understanding Kubernetes: Part 28 ClusterRole and ClusterRoleBinding
        • Understanding Kubernetes: Part 29 Service Account
        • Understanding Kubernetes: Part 30 Horizontal Pod Autoscaler (HPA)
        • Understanding Kubernetes: Part 31 Vertical Pod Autoscaler (VPA)
        • Understanding Kubernetes: Part 33 Startup Probe
        • Understanding Kubernetes: Part 34 Liveness Probe
        • Understanding Kubernetes: Part 35 Readiness Probe
        • Understanding Kubernetes: Part 36 Container Network Interface (CNI)
        • Understanding Kubernetes: Part 37 Container Runtime Interface (CRI)
        • Understanding Kubernetes: Part 38 Container Storage Interface (CSI)
      • Cloudflare
        • Cloudflare Tunnel for Secure HTTP Routing
      • Nginx
        • Nginx use cases that every engineer must know
Powered by GitBook
On this page
  1. Blogs
  2. Medium Articles
  3. Linux

These (Linux) VI Editor Shortcuts You Must Know

Previous40 Powerful Linux Networking Commands You Must Know.NextBash/Linux Interview Questions for DevOps Engineers

Last updated 2 months ago

Linux VI Editor

VI editor is a powerful text editor that is available on almost all Unix-based systems. Whether you’re a system administrator, DevOps engineer, or developer, mastering VI shortcuts can significantly boost your efficiency. Here are some essential shortcuts every user must know.

1. Modes in VI

VI operates in three primary modes:

  • Normal mode: Default mode for navigation and editing commands.

  • Insert mode: Used for inserting text.

  • Command mode: Used for saving, quitting, and other operations.

2. Navigation Shortcuts

  • h → Move left

  • l → Move right

  • j → Move down

  • k → Move up

  • 0 → Move to the beginning of the line

  • ^ → Move to the first non-blank character of the line

  • $ → Move to the end of the line

  • w → Move forward by a word

  • b → Move backward by a word

  • gg → Move to the beginning of the file

  • G → Move to the end of the file

  • Ctrl + d → Scroll down half a page

  • Ctrl + u → Scroll up half a page

3. Editing Shortcuts

  • i → Insert at cursor position

  • I → Insert at the beginning of the line

  • a → Append after cursor

  • A → Append at the end of the line

  • o → Open a new line below

  • O → Open a new line above

  • x → Delete a character

  • dw → Delete a word

  • dd → Delete the current line

  • D → Delete till the end of the line

  • yy → Copy (yank) a line

  • p → Paste after cursor

  • u → Undo last change

  • Ctrl + r → Redo the last undo

4. Search and Replace

  • /text → Search forward for 'text'

  • ?text → Search backward for 'text'

  • n → Repeat the last search in the same direction

  • N → Repeat the last search in the opposite direction

  • :%s/old/new/g → Replace 'old' with 'new' in the entire file

  • :s/old/new/g → Replace all occurrences in the current line

5. Working with Multiple Files

  • :e filename → Open another file

  • :bn → Switch to the next file

  • :bp → Switch to the previous file

  • :w → Save the file

  • :q → Quit VI

  • :wq or ZZ → Save and exit

  • :q! → Quit without saving

6. Advanced Commands

  • v → Start visual selection

  • V → Select an entire line

  • Ctrl + v → Enter visual block mode

  • >> → Indent current line

  • << → Unindent current line

  • :set number → Show line numbers

  • :set nonumber → Hide line numbers

  • :set autoindent → Enable auto-indentation

  • :syntax on → Enable syntax highlighting

Conclusion

Mastering these VI shortcuts will help you navigate and edit files more efficiently. Whether you’re modifying configuration files or writing scripts, knowing these commands will make your workflow smoother. Start practicing today!