How do I customise Vim's status line to show useful file information?
:set statusline=%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
Vim's built-in statusline option lets you build a custom status bar that displays exactly the information you want — without any plugin.
category:
config
tags:
#config
#ex-commands
How do I make Vim automatically reload a file when it changes on disk?
The autoread option tells Vim to automatically re-read a file when it detects the file has been changed outside of Vim.
category:
config
tags:
#config
#ex-commands
#buffers
How do I hide or conceal syntax elements like markdown formatting in Vim?
The conceallevel option controls how Vim displays characters that have the "conceal" syntax attribute.
category:
config
tags:
#config
#formatting
How do you always show the sign column in Vim?
Use set signcolumn=yes to always display the sign column (used by diagnostics, git markers).
category:
config
tags:
#config
#signcolumn
#display
How do you reload your vimrc without restarting Vim?
Use :source $MYVIMRC or :so % if editing the vimrc to reload configuration.
category:
config
tags:
#config
#source
#reload
How do you enable enhanced command-line completion?
set wildmenu wildmode=longest:full,full
Enable wildmenu for a visual menu above the command line.
category:
config
tags:
#config
#wildmenu
#completion
How do you show matching brackets in Vim?
Enable showmatch to briefly highlight the matching bracket when you type a closing bracket.
category:
config
tags:
#config
#brackets
#matching
How do you show relative line numbers in Vim?
Use set relativenumber (or set rnu) to show line numbers relative to the cursor position.
category:
config
tags:
#config
#relative-numbers
#display
How do you display invisible characters like tabs and trailing spaces?
set list listchars=tab:>-,trail:~,extends:>,precedes:<
Enable list and configure listchars to show tabs as >-, trailing spaces as ~, and indicators for text extending beyond the screen.
category:
config
tags:
#config
#invisible
#listchars
How do you show line numbers in Vim?
Use set number (or set nu) to display absolute line numbers in the left margin.
category:
config
tags:
#config
#line-numbers
#display
How do you enable persistent undo across sessions?
set undofile undodir=~/.vim/undo//
Enable undofile and set undodir to persist undo history to disk.
category:
config
tags:
#config
#undo
#persistent
How do you configure line wrapping behavior in Vim?
set wrap linebreak breakindent
Use wrap to wrap long lines, linebreak to break at word boundaries (not mid-word), and breakindent to preserve indentation on wrapped lines.
category:
config
tags:
#config
#wrap
#linebreak
How do you configure swap file location in Vim?
set directory=~/.vim/swap//
Set directory to control where swap files are stored.
category:
config
tags:
#config
#swap
#directory
How do you set the tab width in Vim?
set tabstop=4 shiftwidth=4
Set tabstop for display width of tabs and shiftwidth for indent operations.
category:
config
tags:
#config
#tabs
#width
How do you set automatic line wrapping at a specific column?
Set textwidth (or tw) to automatically insert line breaks when typing past the specified column.
category:
config
tags:
#config
#textwidth
#autowrap
How do you keep context lines visible above and below the cursor?
Set scrolloff (or so) to keep at least 8 lines visible above and below the cursor when scrolling.
category:
config
tags:
#config
#scrolloff
#context
How do you keep context columns when scrolling horizontally?
Set sidescrolloff to keep at least 5 columns visible on each side of the cursor during horizontal scrolling.
category:
config
tags:
#config
#sidescroll
#context
How do you customize the status line in Vim?
set statusline=%f\ %m%r%h\ %=%l,%c\ %P
Configure statusline with format items: %f (filename), %m (modified flag), %= (right-align), %l,%c (line,column), %P (percentage).
category:
config
tags:
#config
#statusline
#custom
How do you configure code folding method in Vim?
Set foldmethod to syntax for language-aware folding, indent for indentation-based, or manual for manual control.
category:
config
tags:
#config
#fold
#method
How do you set a custom leader key in Vim?
Set mapleader to space (or any key) to use as a prefix for custom mappings.
category:
config
tags:
#config
#leader
#key