Overview
Ubiquitous across virtually every Linux distribution, Vim remains the definitive command-line text editor for system administrators and software engineers. This tutorial breaks down Vim’s modal paradigm, operational basics, file manipulation, pattern replacement quirks, and automated command execution through hands-on terminal exercises.
Setting Up Vim and Navigating Modal Editing
Begin by refreshing the APT index on your Ubuntu host and installing the full standard Vim distribution package.

Verify the installed release details and compilation features using vim --version | head -n 2.
⚙️ [Essential CLI Flags]
-R : Launch files in view-only (Read-only) mode.-b : Open target in binary stream editing mode.-o : Tile multiple files across stacked horizontal viewports.-O : Split the terminal screen vertically across multiple files.+숫자 : Jump straight to line number [number] upon buffer launch.-u : Bypass standard runtime configs to source an alternate initialization script.

Set up a sandbox directory to keep these workspace tests isolated, then switch into it via mkdir -p ~/vim_practice && cd ~/vim_practice.

Generate an introductory text payload for our upcoming editor exercises with echo 'Welcome to Linux Vim Editor' > intro.txt.

Confirm that the payload landed cleanly on the filesystem using cat intro.txt.

Creating Buffers, Appending Lines, and Saving Changes
Prepare a multiline mock system configuration file to test in-place editing workflows using printf 'Line 1: System Configuration\nLine 2: Service Status\nLine 3: Port Settings\n' > config_sample.txt.

Run automated normal-mode commands against the buffer to navigate to the bottom line, insert new text below it, and write the buffer to disk:vim -c 'normal! G' -c 'normal! oLine 4: Backup Target' -c 'wq' config_sample.txt
The uppercase G key instructs the cursor to jump directly to the final row in Normal mode, while lowercase o opens a fresh row directly underneath and shifts into Insert mode. Finally, :wq commits all modifications and cleanly exits Vim.

Inspect the updated file on disk using cat config_sample.txt to confirm the appended data persisted.

Global Search, Pattern Substitution, and Syntax Gotchas
Generate a mock server configuration to evaluate global search-and-replace patterns using printf 'server_name=localhost\nserver_port=8080\nserver_env=development\n' > server.conf.

An attempt to automate a global string substitution using double percent syntax failed due to improper command-line escaping, returning E33: No previous substitute regular expression and leaving the target buffer unmodified.
When executing global pattern substitutions inside Vim’s command-line mode, standard regex replacement syntax adheres strictly to :%s/대상문자열/바꿀문자열/g.

Confirm via cat server.conf that the aborted substitution command made zero unauthorized alterations to the configuration file.

Customizing Vim Environments and Managing Lines via .vimrc
Customize your user profile by defining global editor defaults—including active line numbering, four-space soft tabs, indentation widths, and syntax highlighting—via printf 'set number\nset tabstop=4\nset shiftwidth=4\nset expandtab\nsyntax on\n' > ~/.vimrc.

Display the written initialization settings with cat ~/.vimrc to verify parameter assignments.

Automate targeted line deletion on server.conf by directing Vim straight to line 2, executing a row purge, and saving:vim -c 'normal! 2G' -c 'normal! dd' -c 'wq' server.conf
Here, 2G repositions the cursor directly onto the second line (server_port=8080), dd slices out that exact row in Normal mode, and :wq writes the updated buffer back to disk.

Run cat server.conf to verify that the second line was stripped while preserving the surrounding directives.

You now have a solid operational foundation spanning Vim’s modal system, scriptable automation capabilities, and everyday editing commands. Muscle memory develops with practice—incorporating these keys into your daily routine will dramatically accelerate your command-line engineering speed.