Editing in Vim

Vim is not "an editor with hotkeys", it is a language in which you talk to text directly, without button-intermediaries and without graphical babysitters. The mouse gathers dust in a drawer between the charger and a forgotten flash drive, while I sit over someone else's text for the third hour and have not touched it once. Every command here is built like an opcode: one or two symbols on the surface, and behind them a whole semantics refined over decades. We work fast not because we speed up our fingers, but because we stop thinking about them. Below is the grammar: first the simple verbs, then the ones written in several hands and lived down to automatism.

Basic editing commands

Changing the case of words and sentences

Case is the same bit in a byte: flip it and a word goes from a whisper to a shout. Cheap and wicked: a whole line turns over in one gesture, with no dialogs, no modals, no confirmation.

  • gUU — change case to upper for the whole line
  • gUw — change case to upper 'test' => 'TEST'
  • guw — change case to lower for a word
  • ~ — toggle the case of the character under the cursor
  • VU — convert the selected line to upper case
  • Vu — convert the selected line to lower case

Inserting text

The entry point must be explicit — in a disassembler you always know where the instruction pointer jumps, and here it is the same: six ways to say "start writing exactly here".

  • i — enter insert mode before the cursor.
  • I — enter insert mode at the beginning of the current line.
  • a — enter insert mode after the cursor.
  • A — enter insert mode at the end of the current line.
  • o — open a new line below the current one and enter insert mode.
  • O — open a new line above the current one and enter insert mode.

Deleting text

Deleting here is not "erasing" but cutting a piece out of the stream and silently putting it into a register. Nothing is lost: what you removed still lies in memory, waiting.

  • x — delete the character under the cursor.
  • X — delete the character before the cursor.
  • dw — delete a word.
  • dd — delete the current line.
  • D — delete all characters from the cursor to the end of the line.

Changing text

Replacing is deleting with immediate execution, one cycle instead of two. A trifle, yet it saves seconds, and seconds are all of life laid out frame by frame.

  • r — replace the character under the cursor.
  • cw — change a word.
  • cc — change the current line.
  • C — change all characters from the cursor to the end of the line.

Видео «delete-and-change» не найдено (урок не готов или slug неверный).

Copying and pasting

Yank is an old word, but it is more precise than any "copy". You copy not into an abstract clipboard but into a specific register, with a name and an address.

  • y — copy (yank) text.
  • yy — copy the current line.
  • yw — copy a word.
  • p — paste text after the cursor.
  • P — paste text before the cursor.

Undo and repeat

Undo is built like a stack: u returns, Ctrl-R pulls back out what you already buried. And . is a whole separate story — repeating the last command, and it is the most honest form of automation there is: you did it by hand once, and the machine will repeat it as many times as you say.

  • u — undo the last change.
  • Ctrl-R — redo the undone action.
  • . — repeat the last command.

Видео «dot-repeat» не найдено (урок не готов или slug неверный).

Advanced editing commands

Now let us look under the hood: registers, macros, substitutions. This is no longer everyday level, this is the layer where text stops being lines and becomes a stream you can patch on the fly.

Replacing text

:%s is like grep in reverse: found it, replaced it, never asked. A harsh tool, but without illusions.

  • :%s/old/new/g — replace all occurrences of old with new in the file.
  • :s/old/new/g — replace all occurrences of old with new in the current line.
  • :s/old/new/gc — replace all occurrences with confirmation.

Registers

Thirty-odd named memory cells right inside the editor. While others marvel at the clipboard, you work with addressing, as in assembly.

  • "ay — copy text into register a.
  • "ap — paste text from register a.
  • "aP — paste text from register a before the cursor.

Macros

Recording commands into a register and playing them back exactly is a primitive but absolutely reliable interpreter. No plugins, no gurus, only your own hands, caught on film.

  • q<register> — start recording a macro into the given register.
  • q — stop recording the macro.
  • @<register> — play the macro from the given register.
  • @@ — play the last macro.

Autocorrection

Fashionable frameworks promise you three hundred megabytes of intelligence. Vim offers three lines that fix typos before you make them.

:abbr Lunix Linux
:abbr accross across
:abbr hte the

Visual mode

The mouse is not needed here either: selection is a range, and a range then accepts any command.

  • v — enter visual mode.
  • V — enter visual line mode.
  • Ctrl-V — enter visual block mode.
  • d — delete the selected text.
  • y — copy the selected text.
  • > — shift the selected text right.
  • < — shift the selected text left.

Working with buffers and windows

A buffer is a file in memory, a window is a view of it. Keeping these two concepts separate is taught in school, yet corporate IDEs somehow do not.

  • :e filename — open a file.
  • :w — save the file.
  • :q — close the file.
  • :wq — save and close the file.
  • :bd — close the current buffer.
  • :split — split the window horizontally.
  • :vsplit — split the window vertically.
  • Ctrl-W + w — switch between windows.

You can use '*' to jump to the next occurrence of the word under the cursor

Extra

  • J — join the current line with the next one

Видео «join-lines» не найдено (урок не готов или slug неверный).

Conclusion

All these commands are not "a productivity boost" but a way to keep your hands on the levers rather than on the mouse. Text is a stubborn material, and whoever can cut it with registers instead of dragging the cursor letter by letter wins not in speed but in character. Having mastered the coarse gestures first, and then the delicate ones, you will discover an unpleasant thing: you no longer feel like dragging blocks around with the mouse. That is what hardcore is — not for sport, but because the old machine is more honest than the new wrapper.

Useful resources

Read them unhurried and test every command by hand — and the text will start obeying you, not the other way around.