7.2 KiB
Here's a streamlined outline of the VIM guides, focusing on the most relevant and commonly used topics:
I. Copy, Paste, and Find/Replace Operations A. Copy and Paste Lines 1. Copy a Single Line 2. Paste the Copied Line B. Copy and Paste Words 1. Copy a Word 2. Paste the Copied Word C. Find and Replace 1. Find and Replace in the Entire Document 2. Find and Replace in the Current Line 3. Find and Replace with Confirmation
II. Useful Tasks and How to Accomplish Them A. Searching and Navigating B. Indenting and Formatting C. Folding Code D. Working with Registers E. Switching Between Files
III. Visual Mode and Text Selection A. Understanding Visual Mode B. Entering and Exiting Visual Mode C. Selecting Text in Visual Mode D. Operating on Selected Text E. Visual Mode Tips and Tricks
IV. Text Objects and Motions A. Understanding Text Objects B. Word and WORD Text Objects C. Sentence and Paragraph Text Objects D. Code Block Text Objects E. Combining Text Objects with Motions F. Using Text Objects in Visual Mode G. Indentation Text Objects H. Line and Column Text Objects I. Repeating Actions with the Dot Operator
V. Undo and Redo A. Understanding Undo and Redo B. Basic Undo and Redo Commands C. Undo and Redo Tips and Tricks
VI. Buffer Management and Navigation A. Understanding Buffers B. Listing and Switching Buffers C. Opening and Closing Buffers D. Saving and Discarding Changes E. Buffer Navigation
VII. Marks and Jumps A. Understanding Marks B. Setting and Jumping to Marks C. Special Marks D. Jumps and the Jumplist
VIII. Mastering Registers A. Understanding Registers B. Unnamed Register C. Named Registers D. System Clipboard Register E. Read-Only Registers
IX. Customizing VIM with .vimrc A. Understanding .vimrc B. Basic .vimrc Settings C. Mapping Keys in .vimrc D. Customizing VIM Plugins in .vimrc
This streamlined outline focuses on the most essential and commonly used features of VIM that are relevant to a majority of users. It covers copy/paste operations, useful tasks, visual mode, text objects and motions, undo/redo, buffer management, marks and jumps, registers, and basic customization with .vimrc.
Less commonly used topics like persistent undo, advanced buffer management, complex text object manipulations, Vim scripting, and more specialized topics have been removed to keep the guide concise and focused on the most practical features for everyday VIM usage.
Sure! Here's a concise reference guide for the Copy, Paste, and Find/Replace Operations, as well as the Useful Tasks in VIM:
VIM Reference Guide
I. Copy, Paste, and Find/Replace Operations
Copy and Paste Lines
- Copy a line:
yy - Paste after current line:
p - Paste before current line:
P
Copy and Paste Words
- Copy a word:
yiw - Paste after cursor:
p - Paste before cursor:
P
Find and Replace
- Find and replace in the entire document:
:%s/old/new/g - Find and replace in the current line:
:s/old/new/g - Find and replace with confirmation:
:%s/old/new/gc
II. Useful Tasks
Searching and Navigating
- Search for a pattern:
/pattern - Jump to the next occurrence:
n - Jump to the previous occurrence:
N - Jump to a specific line number:
:line_number
Indenting and Formatting
- Indent a block of code:
Vto select lines, then>to indent or<to unindent - Autoindent the entire file:
gg=G - Format a paragraph:
gq}
Folding Code
- Create a fold:
zffollowed by a motion command (e.g.,zf5jto fold the next 5 lines) - Open a fold:
zo - Close a fold:
zc - Open all folds:
zR - Close all folds:
zM
Working with Registers
- Yank text into a named register:
"register_nameyfollowed by a motion command - Paste from a named register:
"register_namep - View the contents of all registers:
:reg
Switching Between Files
- Open a new file in a split window:
- Horizontal split:
:sp filename - Vertical split:
:vs filename
- Horizontal split:
- Switch between open files:
Ctrl-wfollowed byh,j,k, orl - Close the current file:
:q
This reference guide provides a quick overview of the essential copy, paste, find/replace operations, and useful tasks in VIM. Keep this guide handy for quick access to the most commonly used commands and techniques.
Sure! Here's a concise reference guide for Visual Mode and Text Selection, Text Objects and Motions, and Undo and Redo in VIM:
VIM Reference Guide
III. Visual Mode and Text Selection
Entering and Exiting Visual Mode
- Enter character-wise visual mode:
v - Enter line-wise visual mode:
V - Enter block-wise visual mode:
Ctrl-v - Exit visual mode:
EscorCtrl-c
Selecting Text
- Character-wise selection: Use motion commands (
h,j,k,l,w,b) - Line-wise selection: Use
jorkto select entire lines - Block-wise selection: Use motion commands to select a rectangular block
- Select all text:
ggVG
Operating on Selected Text
- Copy (yank) selected text:
y - Cut (delete) selected text:
d - Change selected text:
c - Indent selected text:
>to indent,<to unindent - Convert selected text to uppercase:
U - Convert selected text to lowercase:
u
Visual Mode Tips
- Switch between selection ends:
o - Reselect last visual selection:
gv
IV. Text Objects and Motions
Word and WORD Text Objects
w: word (alphanumeric characters and underscores)W: WORD (non-blank characters separated by whitespace)- Examples:
daw: delete a word (including trailing whitespace)ciW: change inner WORD (excluding surrounding whitespace)yiw: yank inner word (excluding trailing whitespace)
Sentence and Paragraph Text Objects
s: sentence (characters ending with.,!, or?, followed by whitespace or end of line)p: paragraph (block of text separated by blank lines)- Examples:
das: delete a sentence (including whitespace after the sentence)cip: change inner paragraph (excluding surrounding blank lines)yap: yank a paragraph (including surrounding blank lines)
Code Block Text Objects
(,),{,},[,],<,>: code blocks delimited by matching parentheses, braces, brackets, or angle brackets- Examples:
di(: delete inside parenthesesca{: change around curly braces (including the braces)yi[: yank inside square brackets
Combining Text Objects with Motions
- Examples:
d2aw: delete two wordsc3s: change three sentencesy4p: yank four paragraphs
V. Undo and Redo
Basic Undo and Redo Commands
- Undo last change:
u - Redo last undone change:
Ctrl-r - Undo multiple changes: Press
umultiple times - Redo multiple changes: Press
Ctrl-rmultiple times
Undo and Redo Tips
- Undo all changes to a line since entering insert mode:
U - Repeat last change:
.(dot)
This reference guide provides a quick overview of the essential commands and techniques for visual mode and text selection, text objects and motions, and undo and redo in VIM. Keep this guide handy for quick access to these powerful editing features.