github/gitignore · Global/Vim.gitignore

Vim .gitignore Template Explained

A step-by-step look at Vim.gitignore's swap file bracket pattern ([._]*.s[a-v][a-z]), the !*.svg exception, and the session, undo and tags rules.

Open in generator Open with Linux, macOS, C

Vim.gitignore is the template that uses bracket range patterns most aggressively. Vim creates a .filename.swp swap file for each file being edited, and if a swap file already exists it uses a new name by changing the last letter, as in .swo and .swn.

Instead of listing every possible extension, it catches them all at once with ranges such as [a-v][a-z], but that range also includes .svg, so there is a line that restores them with !*.svg.

Rules explained

PatternWhat it ignores and why
[._]*.s[a-v][a-z][._]*.sw[a-p][._]s[a-rt-v][a-z][._]ss[a-gi-z][._]sw[a-p]Swap filesThe first line catches files that start with a dot (.) or underscore (_) and end in .saa through .svz. [._]*.sw[a-p] catches .swa through .swp, and the last three lines catch swap files with no file name before the extension, such as .swp.
!*.svgSVG exception[._]*.s[a-v][a-z] also ignores SVG files that start with a dot or underscore, such as .icon.svg or _logo.svg, so every .svg is re-included. It is an example of why rule order matters.
Session.vimSessionx.vimSessionsWindow layouts and lists of open buffers saved by :mksession. They are personal work state and are not shared.
[._]*.un~*~Undo and backupsPersistent undo files created when the undofile option is on, and backup files from the backup option.
.netrwhisttagsnetrw and tagsVisit history of the built-in file explorer netrw and tag files created by ctags. tags ignores both files and folders named exactly tags.

Practical notes

Original template

Vim.gitignore12 rules
# Swap[._]*.s[a-v][a-z]# comment out the next line if you don't need vector files!*.svg[._]*.sw[a-p][._]s[a-rt-v][a-z][._]ss[a-gi-z][._]sw[a-p]# SessionSession.vimSessionx.vim# Temporary.netrwhist*~# Auto-generated tag filestags# Persistent undo[._]*.un~

Templates from github/gitignore/Global/Vim.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations