Files and Windows Flashcards
zf{textobject}
manually create a fold around the text object
zo
manually open a fold
zc
manually close a fold
Start Vim with a list of files to edit
$vim file1 file2 etc
:args
Show on the status line the files open for editing. The current file is surrounded by brackets.
:n[ext]
Move to the next file.
:wnext
Write the current file and move to the next file
:next!
Move to the next file, abandoning changes to the current file.
:prev[ious]
Move the previous file.
:first
move to the first file
:last
move to the last file
:set (no)autowrite
Turn (off) on autowriting - when moving from file to file Vim will automatically write any changes.
CTRL-^
Jump between current file and the previously edited (the ‘alternate’) file
:edit filename
Opens file ‘filename’ for editing.
“{a-z}[ypd]
Perform the y, p or d operation (followed by each operations motion arguments) on the register specified by a single character from a to z.
Append to file
:write»_space; newfile
Append selection to file
Use visual mode to select a block of text. Then do
:write»_space; newfile
vim -R file
Open the file in Vim as read-only, ! will override
view file
Open the file in Vim as read-only, ! will override
vim -M file
Open the file in Vim as read-only, cannot be overridden.
:saveas name
Saves the current file as a new file named ‘name’
:(count)split
Split the (current) window horizontally, gives new window the height specified by count
CTRL-W w
Jump to another window
:close
Close the current window
:only
Close all windows but the current window
:split filename
Opens filename for editing in the split window
:new
Opens a window on a new, empty file
CTR-W +
Increase size of window
CTRL-W -
Decrease size of window
(count) CTRL-W _
Set window to size specified by count
‘v’ before a window split command
Does the split vertically :vsplit (file), :vnew
CTRL-W [hjkltb]
Move TO the window left, above, down, right, top or bottom.
CTRL-W [HJKL]
Move the window itself to the far left, top, bottom, or right.
:[wq!]all
Writes or quits all open windows, overridden as needed by !.
The -o flag
Opens all arguments as horizontally split windows
The -O flag
Opens all arguments as vertically split windows
:all and :vertical all
Opens all arguments in windows from within vim.
:tab filename
Open filename in a new tab
:tab split
Open a new tab editing the same buffer
:tab
In general, can be prepended to any Ex command that would open a file or window and will open the file or window in a new tab
:tabonly
close all other tabs
(count)gt
Goto Tab (next tab is default, can be specified by the count)
q{register}… q
Begin recording a macro in {register} == [a-z]
…. the ‘q’uit recording.
@{register}
Execute the macro in {register}. May take a count.
@@
Execute the last @{register} command used. May take a count.
Y
== yy. I.e, yank the whole line
Appending to a register
Type out the command as normal but instead of the lowercase letter referencing the register, use an uppercase letter. Example:
qA[commands]q will append [commands] to register a, which is then executed ‘@a’.