Linux
Vim
56 flashcards · answers and spaced-repetition review in the KnowCard app
A newcomer opens a file in Vim and starts typing text, but the keystrokes trigger cursor jumps and deletions instead of appearing on the page. What is going on, and how do they actually start typing?
In Vim standard mode, what is the difference between pressing i and pressing a to start inserting text?
You need to delete 5 lines in Vim from standard mode with the fewest keystrokes. What do you type, and what general rule does this rely on?
You made edits in Vim you want to throw away, and separately, edits you want to keep and exit. Which command-mode commands cover write, quit, force-quit, and save-and-exit?
Vim power users avoid the arrow keys for cursor movement in standard mode. Which single-letter and jump keys replace them?
Vim offers three visual selection modes. When would you reach for Ctrl+V instead of v or V, and how do you copy or delete once selected?
You have several lines selected in Vim and the indentation is wrong. Which commands shift the block in or out, and which one just fixes the indentation automatically?
Your Vim indentation shifts feel too wide. Which option controls the depth of one indent step, and what is its typical default?
Vim has three automatic indent modes — autoindent, smartindent, and cindent. What does each one understand that the previous one does not?
You want to merge the current Vim line with the one below it into a single line. Which key does it, and how do you join several lines at once?
You are editing several files in Vim and want to close everything and leave in one command. Which command exits all buffers, and how does it differ from plain :q?
In Vim, what does :split give you versus :tabnew, and how do you move between tabs?
You run :set on a Vim option and it only takes effect in the file you're editing, not everywhere. Why, and how do you change it for all buffers?
You set your favorite Vim options every session and they vanish when you quit. Where do you put them to persist, and how are comments written in that file?
After a crash, Vim offers to recover your unsaved work. What mechanism makes this possible, what is the file named, and when is it updated?
How does Vim decide which character encoding to use when opening an unknown file, and how do you check what the current file is using?
Which Vim commands turn on line numbers and enable full mouse interaction in a terminal, and what does mouse mode let you do?
You want Vim to insert spaces instead of tab characters. Which option does that going forward, and which command fixes tabs already in the file?
By default Vim never wraps your lines automatically when writing code. How do you turn on an automatic line break for prose, and what happens if the width is left at 0?
Typing long variable and function names in Vim is error-prone. What feature speeds this up, and where does it pull candidate words from?
You try to open a different file in Vim with :e but it refuses and warns about unsaved changes. What is happening, and how do you force it?
In Vim, what is a buffer, and why is a Vim window not the same thing as a window in the graphical desktop?
You have a repetitive multi-step edit to apply many times in Vim. Why is the dot command not enough, and how do you record and replay a macro?
You need to run a shell command from inside Vim without losing your editing session. What are your two options and how do they differ?
You want Vim with real menus and scrollbars in a graphical window. What do you run, and why might it not be installed already?
A beginner wants a hands-on, guided introduction to Vim rather than reading documentation. What command starts one?
In Vim standard mode, how do you undo a change, redo it, and undo every change you made to the current line at once?
Leaving insert mode in Vim nudges the cursor one character left every time. Why, and how do you run a single command without leaving insert mode?
How do you open Vim's help, list every help topic containing a keyword, and move around inside the help window?
You want to drop a bookmark at a spot in a Vim file and jump back to it later. Which commands set and return to such a position?
You're deep in a large file in Vim and want the filename, whether it's modified, and how far through you are. Which key shows this?
In Vim standard mode, how do you jump to a specific line number, to a specific column, and to the bracket matching the one under the cursor?
You need a divider line of fifty = characters in Vim. How do you insert the same character many times without holding a key down?
Vim has two quick fixes for common typing mistakes: a wrong-case letter and two transposed characters. What are they?
Beyond dd and x, how does Vim's d command combine with cursor motions to delete exactly the text you want?
You want to replace a word in Vim and immediately type its replacement in one motion. Which command deletes and enters insert mode together?
How do you copy text in Vim without deleting it — a whole line, or a span defined by a motion?
Vim doesn't wrap code lines, but you're writing prose and want a paragraph re-broken to your line width. Which commands reflow a paragraph?
You've selected a block of lines in Vim and want them sorted. How does Vim let you run a selection through an external command?
How do you search forward and backward in Vim, and repeat the search in each direction?
Vim search accepts regex metacharacters, but some differ from typical regex syntax. How do you match a word boundary, a group, and 'one or more'?
Vim searches are case-sensitive by default. How do you make just one search ignore case, versus all searches?
You want Vim to jump to matches as you type a search and to keep matches highlighted afterward. Which options do that, and how do you clear the highlight?
What is the Vim command to replace every occurrence of abc with efg across the whole file, and how do you add confirmation or case-insensitivity?
In Vim, closing a window that holds a file with unsaved changes can silently lose your work. What buffer behavior explains this?
You launch Vim with three filenames (vim file1 file2 file3) but only see the first. Why, and how do you open each in its own window or tab?
With several buffers open in Vim, how do you list them, jump to a specific one, and close all windows except the current?
Beyond ':set option', what is Vim's full syntax for disabling, inverting, querying, adjusting, and resetting an option?
You type vi on a Linux system and Vim opens instead. Why is the original Vi not there, and how do vi, Vim, and Elvis relate?
Why do administrators favor editors like Vi and Emacs over modern GUI editors, especially on remote or minimal systems?
In Vim's visual mode, how do you extend a selection by a whole word, paragraph, or bracket level, and how do you bring back your last selection?
Rather than programming new Vim features yourself, where do you get ready-made ones, and how do you activate a script?
When typing Vim commands that start with a colon, what three entry helpers speed you up, and where does the command history persist?
Vim doesn't keep a backup of your original file on save by default. How do you turn that on, and what is the backup file named?
A user can't get used to Vim's separate modes. How can Vim be made to stay in insert mode, and how do you still run commands then?
What does launching evim give you, and why does the book suggest it is barely Vim anymore?
Start learning today
Free to start — download the app or use it in your browser.
