How do I open netrw in a left sidebar rooted at the current file's directory?
:Lexplore %:p:h
When you are editing deep in a project, opening netrw from the working directory often puts you in the wrong place.
2125 results for "i" a""
:Lexplore %:p:h
When you are editing deep in a project, opening netrw from the working directory often puts you in the wrong place.
:resize +N / :resize -N
:resize adjusts the height of the current window by a relative or absolute amount.
:Gvdiffsplit!
When reviewing staged versus unstaged changes, jumping between terminal git commands and editor windows is slow.
cnoreabbrev w!! w !sudo tee > /dev/null %
When you forget to open a file with elevated privileges, quitting and reopening can break your flow.
command-line #command-line #abbreviations #sudo #write #workflow
:let s:u=&l:undolevels | setlocal undolevels=-1 | execute "normal! a\<BS>\<Esc>" | let &l:undolevels=s:u
Sometimes you finish a risky refactor and want a clean undo boundary before handing the buffer off or continuing with unrelated edits.
<C-r>=input('Enter: ')<CR>
By embedding =input('prompt: ') inside a recorded macro, you can pause the macro at any point to ask for user input and insert the result.
:'<,'>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
!{motion}{program}
The ! operator in normal mode lets you pipe a range of text through any external program and replace it with the output.
:set nojoinspaces
By default, Vim follows an old typesetting convention and inserts two spaces after a period, exclamation mark, or question mark when joining lines with J.
:%s/\v<(\w+)\s+\1>/\1/g\<CR>
OCR cleanup, copy-paste artifacts, and rushed note-taking often produce repeated words like the the or is is.
vis
The is (inner sentence) text object selects the sentence the cursor is in — excluding any leading or trailing whitespace that separates sentences.
:'<,'>normal {command}
After making a visual selection, :'normal {command} runs any normal-mode command on each selected line individually.
:diffget //2
When resolving Git merge conflicts with vim-fugitive, running :Gvdiffsplit! opens a 3-way split: your current branch (left), the working file with conflict mark
:vimgrep /pattern/ **/*
While external tools like grep or ripgrep are fast, Vim's built-in :vimgrep has a key advantage: it populates the quickfix list directly, so you can jump betwee
/pattern<CR>cgnreplacement<Esc>.
The gn text object selects the next search match, and cgn changes it.
:lua vim.api.nvim_open_win(0, true, {relative='editor', width=80, height=20, row=5, col=10})
Neovim's floating windows hover above the main layout, creating popup-like UI elements.
g??
Vim has a built-in ROT13 operator g? that encodes text by rotating each letter 13 positions in the alphabet.
viw
How it works The command viw selects the word under the cursor in visual mode.
:keepjumps keeppatterns %s/\s\+$//e<CR>
Bulk whitespace cleanup is common, but a plain substitution can leave side effects: your last search pattern changes and jump navigation gets noisy.
qa0f:dwj0q
How it works When recording a macro that you plan to repeat across multiple lines, the key technique is to end the macro positioned on the next line, ready for