How do I insert the current date or time into the buffer using Vim's built-in expression evaluation?
:put =strftime('%Y-%m-%d')
The :put = command inserts the result of a Vimscript expression directly into the buffer as a new line.
:put =strftime('%Y-%m-%d')
The :put = command inserts the result of a Vimscript expression directly into the buffer as a new line.
:set nrformats=
The nrformats option controls which number formats (increment) and (decrement) recognize.
:undolist
Vim's undo history is a tree, not a linear stack.
:[range]center
Vim provides three Ex commands for aligning text within a specified column width: :[range]left, :[range]center, and :[range]right.
command-line #ex-commands #formatting #editing #command-line
:[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
:set shiftwidth=0
Setting shiftwidth=0 tells Vim to use the value of tabstop wherever shiftwidth would normally be consulted — for the > and and in insert mode, and auto-indent
:earlier {time}
Vim's :earlier and :later commands let you travel through undo history using real-world time intervals instead of individual change counts.
:set option!
For any boolean option, appending ! to :set inverts its current value.
do and dp
When comparing files with :vimdiff or :diffthis, Vim highlights each difference as a hunk.
<C-v><Tab>
When expandtab is set, pressing the Tab key inserts spaces instead of a real tab character.
:let @q = substitute(@q, "old", "new", "g")
Vim macros are stored as plain text in registers, which means you can inspect and modify them like any other string.
:g/pattern/t.
Combining :global with the :t (copy) command and the .
:set fileformat=unix
When you open a Windows file in Vim on a Unix system, you may see ^M at the end of every line — that's the carriage return (\r) from CRLF line endings.
:[range]write >> filename
The >> modifier on :write appends lines to a file instead of overwriting it.
command-line #command-line #ex-commands #file-handling #editing
:e ++enc=utf-8
When Vim opens a file with the wrong encoding — producing garbled text or incorrect characters — you can reload it with a specific encoding using :e ++enc={
:set foldmarker=region,endregion
When using foldmethod=marker, Vim looks for the strings in foldmarker to identify fold boundaries.
:noautocmd w
The :noautocmd modifier runs any Ex command while suppressing all autocmd events for its duration.
:center / :left / :right
Vim has three built-in Ex commands for aligning text without any plugins: :left, :center, and :right.
1000@q
Vim macros stop executing the moment any step in the macro causes an error — a failed search, a motion that cannot proceed, or a substitution with no matches.
vipgq
The vipgq sequence reflowing a paragraph to fit within the width defined by textwidth (default 0, meaning no limit).