How do I set different Vim options for specific programming languages?
autocmd FileType python setlocal ts=4 sw=4 et
Using autocmd FileType, you can configure Vim to automatically apply buffer-local settings whenever a file of a particular type is opened.
category:
config
tags:
#config
#ex-commands
#editing
#formatting
How do I fix broken or incorrect syntax highlighting in Vim?
Vim's syntax highlighting engine does not always parse the entire file from the beginning — it uses sync points to determine where to start parsing for the vi
category:
config
tags:
#config
#ex-commands
#editing
How do I create a custom operator that works with motions and text objects?
:set operatorfunc=MyFunc<CR>g@
Vim lets you define custom operators that behave like built-in ones (d, c, y) — they wait for a motion or text object, then act on the selected region.
category:
config
tags:
#config
#normal-mode
#motions
#text-objects
#mapping
How do I profile Vimscript functions to find what is slowing down Vim at runtime?
:profile start profile.log | profile func *
When Vim feels sluggish during editing—not just at startup—you need runtime profiling to pinpoint which functions are consuming the most time.
category:
config
tags:
#profiling
#debugging
#config
#ex-commands
#performance
How do I profile Vim functions at runtime to find what's making it slow?
:profile start /tmp/profile.log | profile func *
When Vim feels sluggish during editing (not just at startup), the :profile command lets you measure the execution time of every function call.
category:
config
tags:
#ex-commands
#config
#debugging
How do I create a custom operator that works with any motion in Vim?
:set operatorfunc=MyFunc<CR>g@{motion}
Vim's operatorfunc and g@ let you define custom operators that accept any motion or text object, just like built-in operators d, c, and y.
category:
config
tags:
#config
#mapping
#normal-mode
#editing
How do I find which syntax highlighting rules are slowing down Vim?
When Vim feels sluggish while editing files with complex syntax highlighting, :syntime lets you profile exactly which syntax rules are consuming the most time.
category:
config
tags:
#syntax
#profiling
#performance
#config
How do I increment or decrement hexadecimal and binary numbers with Ctrl-A and Ctrl-X?
By default, Vim's and only increment and decrement decimal numbers.
category:
config
tags:
#editing
#config
#normal-mode
How do I find out what is making Vim slow to start up?
vim --startuptime /tmp/vim-startup.log
When Vim takes too long to start, the --startuptime flag writes a detailed timing log showing exactly how long each plugin, script, and initialization step take
category:
config
tags:
#config
#debugging
#performance
#ex-commands
How do I enable persistent undo so undo history survives closing files?
:set undofile undodir=~/.vim/undodir
By default, Vim's undo history is lost when you close a file.
category:
config
tags:
#config
#undo
#persistent
#undofile
How do I create custom highlight groups and override colorscheme colors?
:highlight MyGroup guifg=#ff0000 guibg=NONE gui=bold
The :highlight command lets you define custom colors for syntax elements, UI components, and your own highlight groups.
category:
config
tags:
#config
#highlight
#colors
#customization
How do I customize what Vim considers a 'word' for motions and text objects?
The iskeyword option defines which characters are part of a "word" for motions like w, b, e, , and text objects like iw.
category:
config
tags:
#config
#iskeyword
#word-boundary
#customization
How do I embed Vim settings inside a file using modelines?
Modelines are special comments at the top or bottom of a file that Vim reads to apply file-specific settings.
category:
config
tags:
#config
#modeline
#per-file
#settings
How do I configure Vim to find files recursively in subdirectories?
Adding to the path option tells Vim to search recursively through all subdirectories when using :find, gf, and other path-related commands.
category:
config
tags:
#config
#path
#find
#file-navigation
How do I change the cursor shape for different Vim modes in the terminal?
Modern terminals support cursor shape changes via escape sequences.
category:
config
tags:
#config
#cursor
#terminal
#visual-feedback
How do I control automatic text wrapping and comment formatting in Vim?
The formatoptions setting controls how Vim automatically formats text as you type — including comment continuation, auto-wrapping, and paragraph formatting.
category:
config
tags:
#config
#formatting
#comments
#text-wrapping
How do I configure Vim to use ripgrep as its built-in grep program?
:set grepprg=rg\ --vimgrep
Vim's :grep command uses an external program to search files and populate the quickfix list.
category:
config
tags:
#config
#grep
#ripgrep
#search
How do I make gf find files even when the import path omits the file extension?
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
category:
navigation
tags:
#navigation
#config
#editing
How do I select a rectangular block past the end of shorter lines in visual block mode?
By default, Vim's visual block mode () is limited by line length — if some lines are shorter than others, the block selection gets ragged.
category:
visual-mode
tags:
#visual-mode
#editing
#config
#indentation
How do I change which characters Vim treats as part of a word for motions and text objects?
iskeyword defines which characters are considered word characters in Vim.
category:
config
tags:
#config
#editing
#search