.gitignore for Vim

12 ignore rules for Vim, ready to copy into your repository.

Highly configurable text editor

The complete .gitignore for Vim

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-08-05 01:27:29 UTC
# Technologies: Vim

### Vim ###
# Vim swap files pattern
[._]*.s[a-v][a-z]
!*.svg
# Vim swap files pattern
[._]*.sw[a-p]
# Vim swap variant
[._]s[a-rt-v][a-z]
# Vim session files
[._]ss[a-gi-z]
# Vim swap pattern
[._]sw[a-p]
# Vim session file
Session.vim
# Vim extra session file
Sessionx.vim
# Vim netrw history
.netrwhist
# Emacs backup files
*~
# Vim tags file
tags
[._]*.un~

What these Vim rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Swap

Pattern What it ignores
[._]*.s[a-v][a-z] Vim swap files pattern
!*.svg comment out the next line if you don't need vector files
[._]*.sw[a-p] Vim swap files pattern
[._]s[a-rt-v][a-z] Vim swap variant
[._]ss[a-gi-z] Vim session files
[._]sw[a-p] Vim swap pattern

Session

Pattern What it ignores
Session.vim Vim session file
Sessionx.vim Vim extra session file

Temporary

Pattern What it ignores
.netrwhist Vim netrw history
*~ Emacs backup files

Auto-generated tag files

Pattern What it ignores
tags Vim tags file

Persistent undo

Pattern What it ignores
[._]*.un~ Persistent undo

How to use this .gitignore for Vim

  1. Copy the Vim rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Editor .gitignore templates

See every Editor template