How do I reference just the filename without its extension in a Vim command?
%:r
The %:r expression expands to the current filename with its extension removed (the "root" of the filename).
488 results for ":e!"
%:r
The %:r expression expands to the current filename with its extension removed (the "root" of the filename).
:argdo %s/foo/bar/ge | update
Bulk replacements across many files are risky when every buffer gets written unconditionally.
qa...@aq
A recursive macro calls itself at the end of its recording, causing it to repeat until a motion or search fails.
:sball
The :sball command (short for split all) opens every loaded buffer in its own horizontal split window in one shot.
set foldmarker=start,end
When using foldmethod=marker, Vim uses {{{ and }}} as the default fold open and close markers.
<C-k>{digraph}
Vim's digraph system lets you insert special characters, accented letters, and symbols by typing a memorable two-character sequence.
:w ++p
Neovim's :w ++p flag automatically creates any missing intermediate directories when writing a file.
:cq
The :cq command quits Vim and returns a non-zero exit code to the calling process.
,
After using f, t, F, or T for single-character motion on a line, Vim lets you repeat that character search without retyping the target.
qq;.q then @q or @@
The dot command (.
:argdo %s/old/new/g | update
The :argdo command runs an Ex command on every file in the argument list (the files you opened Vim with, or added via :argadd).
:saveas
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
:cfdo %s/\<GetUser\>/FetchUser/ge | update
When quickfix has many matches per file, :cdo can execute your command repeatedly in the same buffer.
command-line #command-line #quickfix #refactoring #ex-commands #search
gg
The gg command moves the cursor to the first line of the file.
:g/^/m 0
This clever use of the :global command reverses every line in the current buffer.
command-line #editing #ex-commands #global #text-manipulation
:view {file}
:view opens a file with the readonly option set, preventing accidental writes.
:g/^/m0
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
\d \w \s \a \l \u
How it works Vim provides shorthand character classes that save you from writing out full bracket expressions.
:args {pattern}
The :args command sets Vim's argument list to all files matching a glob pattern.
:noautocmd {command}
The :noautocmd prefix (abbreviated :noa) suppresses all autocommand events for the duration of the following command.
command-line #ex-commands #autocommands #performance #command-line #scripting