How do I convert text to title case in Vim using a substitution command?
Vim's substitution engine supports case-modifier sequences in the replacement string, making it possible to convert text to title case in a single command.
category:
search
tags:
#search
#substitution
#regex
#editing
#case
#formatting
How do I control how many columns Vim scrolls horizontally at once when the cursor reaches the screen edge?
When wrap is off and the cursor moves past the edge of the screen, Vim jumps the view horizontally by a number of columns determined by sidescroll.
category:
config
tags:
#config
#navigation
#editing
How do I save just the visually selected lines to a new file?
After making a visual selection, you can write only those lines to a new file using :'w {filename}.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
How do I sort lines in Vim without caring about upper or lower case?
By default, :sort uses byte-value ordering, which places all uppercase letters before lowercase.
category:
command-line
tags:
#editing
#ex-commands
#command-line
How do I sort lines while ignoring a leading prefix like a key or label?
The :sort /{pattern}/ command sorts lines by their content after the first match of the pattern.
category:
command-line
tags:
#editing
#ex-commands
#command-line
How do I get just the filename without its path or extension to use in a command?
Vim's % special character expands to the current filename and accepts a chain of colon-delimited modifiers.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#navigation
How do I run an external shell command from Vim without the press-enter prompt afterward?
Running :!cmd in Vim shows the command's output and then pauses with a "Press ENTER or type command to continue" prompt.
category:
command-line
tags:
#command-line
#ex-commands
#shell
#editing
How do I force-convert all indentation including tabs in the middle of lines throughout an entire file?
The :retab command converts leading whitespace according to the current tabstop and expandtab settings, but it only touches indentation at the start of lines.
category:
editing
tags:
#editing
#indentation
#formatting
#ex-commands
How do I restrict a substitution to the range between two named marks?
Named marks can serve as range endpoints for any Ex command, including :substitute.
category:
search
tags:
#search
#marks
#substitution
#ex-commands
#editing
How do I quickly delete all lines in the current buffer?
The % range address in Ex commands stands for the entire file — it is shorthand for 1,$ (first line to last line).
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I jump to the local or global declaration of the variable under the cursor without ctags?
Vim's gd and gD commands jump to the declaration of the identifier under the cursor by searching upward through the file — no ctags setup required.
category:
navigation
tags:
#navigation
#editing
#normal-mode
How do I edit a macro without re-recording it?
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I step through the files in my argument list one at a time?
When Vim is opened with multiple files (e.
category:
command-line
tags:
#buffers-windows
#ex-commands
#navigation
#editing
How do I run a substitute or filter command without Vim automatically repositioning my marks?
When Vim executes commands that move or reorder lines — such as :sort, :%!sort, or :s/// across ranges — it automatically adjusts named marks to follow the
category:
command-line
tags:
#ex-commands
#marks
#editing
#normal-mode
How do I instantly erase everything I have typed on the command line and start the command over?
When you are typing a long Ex command on the : prompt and realise you've made a mistake, pressing erases everything from the cursor back to the beginning of the
category:
command-line
tags:
#command-line
#ex-commands
#editing
#insert-mode
How do I use a count with text objects to operate on multiple text objects at once?
Text objects in Vim accept a count, letting you operate on a span of multiple adjacent text objects in one command.
category:
editing
tags:
#editing
#text-objects
#normal-mode
How do I reference just the filename without its extension in a Vim command?
The %:r expression expands to the current filename with its extension removed (the "root" of the filename).
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I force a case-insensitive substitution without changing the global ignorecase setting?
:%s/pattern/replacement/ig
The :s substitute command accepts /i and /I flags that override your global ignorecase and smartcase settings for that single substitution, letting you choose c
category:
search
tags:
#search
#editing
#ex-commands
#normal-mode
How do I open the command-line window while I am already typing a command?
<C-f> (command-line mode)
Pressing while in the command-line (:, /, or ? prompt) opens the command-line window with your partially-typed command already loaded and ready for full Vim edi
category:
command-line
tags:
#command-line
#ex-commands
#editing
#navigation
How do I paste text before the cursor while leaving the cursor positioned after the pasted content?
The gP command works like P (paste before the cursor) but leaves your cursor after the pasted text rather than at its beginning.
category:
editing
tags:
#editing
#paste
#registers
#normal-mode