How do I make Vim open new splits below and to the right instead of above and left?
:set splitbelow splitright
How it works By default, Vim opens horizontal splits (:split or :sp) above the current window and vertical splits (:vsplit or :vsp) to the left.
category:
config
tags:
#windows
#navigation
How do I set a colorscheme with a fallback in case it is not installed?
try | colorscheme gruvbox | catch | colorscheme default | endtry
How it works When you share your vimrc across multiple machines, a colorscheme you have installed on one system may not exist on another.
category:
config
tags:
#editing
#formatting
How do I stop Vim from creating backup and swap files in my project directories?
:set backupdir=~/.vim/backup// directory=~/.vim/swap//
How it works By default, Vim creates backup files (ending in ~) and swap files (ending in .
category:
config
tags:
#editing
#buffers
How do I configure Vim to auto-save files when I switch away?
:set autowriteall and autocmd FocusLost * silent! wa
How it works Vim can be configured to automatically save your files when you switch to another window or application.
category:
config
tags:
#editing
#buffers
How do I enable smart case-sensitive searching in Vim?
:set ignorecase smartcase
How it works By setting both ignorecase and smartcase, Vim uses an intelligent case sensitivity rule for searches: If your search pattern is all lowercase, the
category:
config
tags:
#search
#editing
How do I make Vim highlight matching brackets when typing?
How it works The :set showmatch option makes Vim briefly jump the cursor to the matching opening bracket when you type a closing bracket.
category:
config
tags:
#editing
#navigation
How do I enable mouse support in Vim?
How it works The :set mouse=a command enables mouse support in all Vim modes.
category:
config
tags:
#navigation
#editing
How do I toggle line wrapping on or off in Vim?
:set wrap! or :set nowrap
How it works By default, Vim wraps long lines that extend past the window width, displaying them across multiple screen lines.
category:
config
tags:
#visual-mode
#formatting
#navigation
How do I customize Vim's statusline to show useful file information?
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
category:
config
tags:
#config
#formatting
How do I build a custom statusline without plugins?
:set statusline=%f\ %m%r%h%w\ %=%l/%L\ %p%%
Vim's statusline option accepts printf-style format codes that display file info, position, mode, and any custom expression.
category:
config
tags:
#config
#statusline
#vimrc
#customization
How do I use the leader key to create my own keyboard shortcuts?
let mapleader = ' ' then nnoremap <leader>key command
The leader key is a configurable prefix for your custom key mappings.
category:
config
tags:
#config
#mappings
#vimrc
#leader
#workflow
How do I configure Vim to share the clipboard with my system?
:set clipboard=unnamedplus
Setting clipboard=unnamedplus makes Vim's default yank and paste use the system clipboard.
category:
config
tags:
#config
#clipboard
#system-integration
#vimrc
How do I override plugin or filetype settings that load after my vimrc?
~/.vim/after/ftplugin/{filetype}.vim
Vim's after directory (~/.
category:
config
tags:
#config
#vimrc
#filetype
#plugins
#customization
How do I write autocommands that don't duplicate when I reload my vimrc?
augroup name | autocmd! | autocmd ... | augroup END
Autocommand groups (augroup) with autocmd! prevent duplicate autocommands from accumulating every time you source your vimrc.
category:
config
tags:
#config
#autocommands
#vimrc
#best-practices
How do I create custom fold regions with markers in my code?
Setting foldmethod=marker lets you define fold boundaries using special comment markers — {{{ to start a fold and }}} to end it.
category:
config
tags:
#config
#folding
#organization
#vimrc
How do I automatically fold code based on indentation level?
Setting foldmethod=indent tells Vim to create folds based on the indentation level of each line.
category:
config
tags:
#config
#folding
#indentation
#code-navigation
How do I create custom text objects for my own operator-pending motions?
onoremap ih :<C-u>execute "normal! ?^==\+$\r:noh\rkvg_"<CR>
Vim lets you define custom text objects using operator-pending mode mappings (onoremap) and visual mode mappings (vnoremap).
category:
config
tags:
#config
#text-objects
#mappings
#vimrc
#advanced
How do I get a visual tab-completion menu for Vim commands and filenames?
The wildmenu option enhances Vim's command-line completion by showing a horizontal menu of matches above the command line when you press .
category:
config
tags:
#config
#command-line
#completion
#productivity
#vimrc
How do I switch between buffers without being forced to save first?
By default, Vim refuses to let you switch away from a buffer that has unsaved changes, forcing you to save or discard with :w or :e! before moving on.
category:
config
tags:
#config
#buffers
#vimrc
#productivity
#workflow
How do I make Vim automatically jump to where I last edited when reopening a file?
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Vim remembers the last cursor position for every file you edit (stored in the viminfo or shada file), but by default it opens files at line 1.
category:
config
tags:
#config
#autocmd
#navigation
#vimrc
#productivity