How do I configure :make to run the current file as a script with a specific interpreter?
:set makeprg=python3\ %
Setting makeprg to include % lets :make always execute the file you're currently editing.
Search Vim Tricks
Searching...:set makeprg=python3\ %
Setting makeprg to include % lets :make always execute the file you're currently editing.
:e $MYVIMRC
The :e $MYVIMRC command opens your Vim or Neovim configuration file instantly, no matter where it lives.
:mkspell ~/.vim/spell/en.utf-8.add
When you add words to your personal spell file with zg, Vim writes them to a plain-text .
qa{motions}@aq
A recursive macro is one that calls itself at the end of its own recording.
:'<,'>w !{cmd}
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.
:set winminheight=0
By default, Vim enforces a minimum window height of 1 line, which means you can never fully collapse a split.
buffers-windows #buffers-windows #windows #splits #navigation
<C-f> (from command-line)
When you are already in the middle of typing a command (after pressing :) and realize you need to compose something complex — a long substitution, a multi-pip
[#
Vim includes built-in motions for navigating C preprocessor conditional blocks: [# jumps backward to the previous unmatched #if or #else, and ]# jumps forward t
g-
Vim's undo history is a tree, not a linear stack.
gwap
The gw operator reformats text to fit within 'textwidth' — identical in effect to gq, but with one key difference: the cursor returns to its original position
qa<C-a>jq
By recording a one-step macro that increments a number and moves down a line, you can bulk-apply across as many lines as needed with a single count.
d3aw
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
editing #text-objects #editing #delete #normal-mode #motions
gh
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection a
:set concealcursor=nv
The 'concealcursor' option controls in which modes concealed text is revealed on the cursor line.
:w ++ff=unix
The ++ff modifier on :w forces the file format used for writing, independently of the buffer's 'fileformat' option.
command-line #ex-commands #formatting #command-line #editing
:cexpr []
After a :grep, :make, or :vimgrep run, the quickfix list fills with results.
command-line #command-line #buffers-windows #quickfix #ex-commands
:put =execute('messages')
Vim's :messages command shows recent output — error messages, echo'd values, and diagnostic information — but the display is ephemeral and hard to search.
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
editing #search #editing #substitution #ex-commands #normal-mode
:%!python -m json.tool
When editing JSON files in Vim, you can pipe the entire buffer through Python's built-in json.
:%s/\v(\w+)/\u\L\1/g
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.
search #search #substitution #regex #editing #case #formatting