How do I save a file under a new name in Vim?
:saveas
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
2277 results for "@a"
:saveas
The :saveas {filename} command writes the current buffer to a new file and makes that new file the current buffer's file.
:[range]sort /regex/
The :[range]sort /regex/ command sorts lines while skipping the portion of each line that matches the regex.
:setlocal statusline=%f\ %m\ %y\ [%l/%L]
The :setlocal statusline command lets you override the global statusline for a specific window.
:g/pattern/t.
Combining :global with the :t (copy) command and the .
:%s/pattern/\=expr/g
Prefixing the replacement field of :s with \= tells Vim to evaluate the rest as a Vimscript expression and use its result as the replacement string.
:v/pattern/command
:v (short for :vglobal) is the inverse of :g.
\%[abc]
The \%[.
\d \w \s \a \l \u
How it works Vim provides shorthand character classes that save you from writing out full bracket expressions.
:set mousemodel=extend
If you use the mouse occasionally in Vim, mousemodel=extend makes selection behavior much more predictable.
:let @q =
Instead of recording a macro with q, you can assign any string directly to a named register using :let @{register} = 'keys'.
r{char} in visual mode
In visual mode, pressing r followed by a character replaces every character in the selection with that single character.
:'<,'>s/\n/, /g
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
editing #editing #ex-commands #visual-mode #substitution #lines
:g/^$/,/./-j
The command :g/^$/,/.
' vs `
Vim provides two distinct ways to jump to a mark, and they behave differently: the apostrophe ' jumps to the first non-blank character of the marked line, while
<C-\><C-o>
In a Neovim terminal buffer, exits to normal mode permanently.
buffers-windows #terminal #buffers-windows #insert-mode #neovim #normal-mode
qaA;<Esc>jq
This macro appends a semicolon to the current line and moves down, ready to repeat.
"=strftime('%F')<CR>p
The expression register lets you compute text on demand and insert it without leaving Normal mode workflows.
registers #registers #expression-register #normal-mode #automation
50%
Prefixing the % command with a count jumps the cursor to that percentage through the file.
/\%>10l\%<20lTODO
Vim regex supports position atoms that can constrain where a match is allowed to occur.
:g/pattern/.,+2d
Inside a :global command, .
command-line #ex-commands #global #delete #editing #command-line