How do I select an entire code block from opening brace to closing brace in visual mode?
V%
Pressing V% enters visual line mode on the current line and immediately extends the selection to the line containing the matching bracket or brace.
V%
Pressing V% enters visual line mode on the current line and immediately extends the selection to the line containing the matching bracket or brace.
:clearjumps
The :clearjumps command wipes the jump list for the current window, giving you a clean slate for and navigation.
set sidescrolloff
set sidescrolloff={n} keeps at least n columns of context to the left and right of the cursor when long lines cause the view to scroll horizontally.
+
The + command moves the cursor to the first non-blank character of the next line.
zs and ze
When nowrap is set and lines extend beyond the screen width, zs and ze snap the horizontal scroll position so the cursor sits exactly at the left or right edge
<C-w>g<C-]>
Pressing g jumps to the definition of the tag under the cursor — just like — but opens the destination in a new horizontal split window.
:w !diff % -
The command :w !diff % - pipes the current buffer's contents to an external diff command that compares it against the saved file on disk.
buffers-windows #buffers-windows #ex-commands #editing #navigation
:set autochdir
The autochdir option tells Vim to automatically change the current working directory to the directory of the file in the active window whenever you switch buffe
:sp +/{pattern} {file}
The +{cmd} syntax lets you run an Ex command immediately after a file is opened.
:keepjumps {cmd}
:keepjumps is a command modifier that suppresses any jump list updates caused by the command that follows it.
:cnoremap %% <C-r>=expand('%:h').'/'<CR>
By mapping %% in command-line mode, you can type %% wherever you would normally type a path and have Vim automatically expand it to the directory of the current
<C-r><C-l>
Pressing on the command line inserts the full text of the current buffer line (the line the cursor is on when you pressed :) directly at the command-line cursor
:set switchbuf=useopen
The switchbuf option controls how Vim decides where to display a buffer when switching to it via commands like :sb, :cc, :cn, quickfix jumps, or .
buffers-windows #buffers-windows #navigation #ex-commands #config
[/ and ]/
Vim provides two motions for navigating C-style block comments (/ .
g+ and g-
Vim's undo history is a tree, not a linear stack.
[{ and ]}
The [{ motion jumps to the previous unmatched { — the opening brace of the block enclosing your cursor.
:args **/*.js
The :args command populates Vim's argument list with files matching a glob pattern, turning any set of files into a navigable list and enabling project-wide bat
V]}
Pressing V]} in normal mode enters visual line mode and immediately extends the selection to the next unmatched closing brace }.
visual-mode #visual-mode #navigation #text-objects #editing #motions
- (vim-vinegar)
The vim-vinegar plugin by Tim Pope enhances Neovim's built-in netrw file browser.
packadd matchit
Vim ships with matchit.