How do I re-open a file in Vim with a specific encoding without restarting?
:e ++enc={encoding}
When Vim auto-detects the wrong character encoding — mojibake where é shows as é is a classic symptom — you can reload the current buffer with a specifi
:e ++enc={encoding}
When Vim auto-detects the wrong character encoding — mojibake where é shows as é is a classic symptom — you can reload the current buffer with a specifi
%:t:r
Vim's % special character expands to the current filename and accepts a chain of colon-delimited modifiers.
command-line #command-line #ex-commands #editing #navigation
:silent !{cmd}
Running :!cmd in Vim shows the command's output and then pauses with a "Press ENTER or type command to continue" prompt.
:%d
The % range address in Ex commands stands for the entire file — it is shorthand for 1,$ (first line to last line).
:Man {name}
Neovim ships with a built-in :Man command (the man.
command-line #neovim #navigation #documentation #command-line
:compiler
Vim ships with built-in compiler plugins for many languages and tools — including gcc, python, cargo, eslint, tsc, and more.
command-line #ex-commands #config #buffers-windows #command-line
<C-u> (command line)
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
command-line #command-line #ex-commands #editing #insert-mode
%:r
The %:r expression expands to the current filename with its extension removed (the "root" of the filename).
:debug
The :debug command prefix puts Vim into its built-in interactive debugger before executing the given command.
command-line #ex-commands #debugging #command-line #vimscript
<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
command-line #command-line #ex-commands #editing #navigation
vim.api.nvim_create_user_command()
Neovim's Lua API provides vim.
:set wildmode=longest,list
By default, Vim's command-line completion just cycles through matches one at a time.
:{range}center {width}
Vim has built-in Ex commands for text alignment: :center, :right, and :left.
command-line #ex-commands #formatting #editing #command-line
:normal! {cmds}
:normal {cmds} executes normal-mode keystrokes from the command line, but it honors your custom key mappings — so remapped keys produce unexpected results in
command-line #ex-commands #macros #normal-mode #command-line
:/pattern/+N and :/pattern/-N
Vim's Ex command ranges can use search patterns as line addresses, and those addresses can include a numeric offset (+N or -N) to target lines relative to the m
:Cfilter /pattern/
Vim ships with an optional built-in package called cfilter that adds :Cfilter and :Lfilter commands for narrowing down quickfix and location list entries by pat
:g/pattern/put ='text'
Combining :global with :put = lets you insert synthesized lines of content after every line matching a pattern — without plugins or complex macros.
:%TOhtml
Vim ships with a built-in plugin that converts the current buffer into a standalone HTML file, complete with your exact syntax highlighting colors.
<C-z> / :stop
Pressing in Vim sends it to the background of your shell session — just like suspending any Unix process.
set wildmode=longest:list,full
Setting wildmode=longest:list,full gives Vim a completion behavior similar to shells like bash and zsh.