How do I reference just the extension, stem, or directory of the current file in a Vim command?
%:e
Vim exposes the current filename as % in Ex commands, and you can apply modifiers to extract specific parts of the path.
795 results for "g* g#"
%:e
Vim exposes the current filename as % in Ex commands, and you can apply modifiers to extract specific parts of the path.
:bufdo {cmd}
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.
getreg()
The getreg({name}) function returns the content of any register as a string.
z{N}<CR>
The z{N} command sets the current window's height to exactly N lines and simultaneously positions the current line at the top of the window.
:set nostartofline
By default, many Vim movement commands — gg, G, Ctrl-d, Ctrl-u, Ctrl-f, Ctrl-b, and others — snap the cursor to the first non-blank character of the destina
:sign define and :sign place
Vim's built-in sign system lets you define custom symbols and place them in the sign column — the narrow gutter to the left of line numbers.
vim.diagnostic.count()
vim.
~ (in visual mode)
In visual mode, pressing ~ toggles the case of every character in the selection.
:ls
The :ls command displays a list of all open buffers in Vim, showing their buffer number, status indicators, file name, and the line the cursor was last on.
* (in visual mode)
In normal mode, searches for the word under the cursor with word-boundary anchors.
:set incsearch hlsearch
The combination of incsearch and hlsearch gives you live, interactive search highlighting.
:[range]norm @{register}
The :normal command executes normal-mode keystrokes on each line in a range — including macro playback.
vim.keymap.set
vim.
\%(pattern\)\@=
Vim's lookahead assertion \@= confirms that the current position is followed by a pattern — without including those characters in the match.
:'<,'>norm {commands}
The :normal (or :norm) command lets you execute normal mode keystrokes from the command line.
command-line #editing #ex-commands #normal-mode #productivity #ranges
autocmd BufNewFile *.py 0r ~/.vim/templates/python.py
When you create a new file in Vim (e.
:[range]normal @a
The :[range]normal @a command runs a recorded macro against every line in a given range.
macros #macros #registers #ex-commands #normal-mode #advanced
<C-\><C-o>
In a Neovim terminal buffer, exits to normal mode permanently.
buffers-windows #terminal #buffers-windows #insert-mode #neovim #normal-mode
:[range]yank {reg}
Vim's :[range]yank and :[range]delete Ex commands let you capture arbitrary line ranges into a register from the command line, bypassing the need to move the cu
:Oil
oil.