📝 Vim Configuration
A modular vim configuration split into two main files for better organization and flexibility.
📂 Files Overview
config.vim - Core vim settings, mappings, and basic functionality
plugins.vim - Plugin management, installation, and plugin-specific configurations
AUDIT.md - Known issues found by code audit
CLAUDE.md - Guidance for AI assistants working on this config
📋 Requirements
- Vim 8.2+ (
config.vim uses smoothscroll, which needs Vim 9.0.0640+; on older
versions that one line reports E518 and the rest of the config still loads)
curl and git - required to bootstrap vim-plug and fetch plugins
Optional, per plugin:
| Needed for |
Requirement |
Tagbar (<F8>) |
ctags (universal-ctags recommended) |
| vim-airline symbols |
A powerline-patched or Nerd Font |
| ALE JavaScript fixers |
node + eslint |
<F5> / <F6> runners |
python3, node, bash, ruby, or perl |
⚡️ Setup Instructions
Clone the repository. The paths below assume ~/config_vim — adjust them if you
clone elsewhere:
git clone https://github.com/Code-Samples-Galore/Config-Vim.git ~/config_vim
1️⃣ Option 1: Basic Configuration (No Plugins)
If you only want the core vim settings without plugins, add this to your ~/.vimrc:
" Source basic vim configuration
source ~/config_vim/config.vim
2️⃣ Option 2: Full Configuration (With Plugins)
For the complete setup including automatic plugin management, add this to your ~/.vimrc:
" Source plugin management and configurations
source ~/config_vim/plugins.vim
" Source basic vim configuration
source ~/config_vim/config.vim
Note: Source plugins.vim first to ensure plugins are loaded before the main configuration.
On first launch, vim-plug is downloaded automatically and the plugins are installed.
Expect a few errors on that very first start (the gruvbox colorscheme does not exist
yet) — restart Vim once installation finishes.
✨ Features
⚙️ Core Configuration (config.vim)
- Optimized display settings with line numbers and syntax highlighting
- Smart indentation and formatting rules
- Enhanced search functionality
- Custom key mappings and leader shortcuts
- Automatic file handling and backup management
- Custom status line showing mode, git branch and file size
- Auto-closing brackets and quotes
- File-type specific settings
The custom status line is only visible in the no-plugin setup. With Option 2,
vim-airline replaces it with its own.
🔌 Plugin Management (plugins.vim)
- Automatic vim-plug installation
- Auto-installation of missing plugins
- Periodic plugin updates (every 7 days)
- Configured plugins:
- gruvbox - Color scheme
- NERDTree - File explorer
- vim-airline - Enhanced status line
- vim-polyglot - Language pack
- vim-commentary - Easy commenting
- vim-surround - Surround text objects
- ALE - Asynchronous linting
- Tagbar - Code structure overview
- IndentLine - Visual indentation guides
⌨️ Key Mappings
The leader key is , (comma).
Editing
| Mapping |
Action |
jj |
Exit insert mode |
<space> |
Enter command mode (types :) |
o / O |
Open a blank line below/above and stay in normal mode |
Y |
Yank from cursor to end of line |
j / k |
Move by display line (gj/gk) |
<CR> |
Clear search highlighting |
n / N |
Next/previous search match, centered |
<leader>, |
Jump back to the last cursor position |
Files and buffers
| Mapping |
Action |
<leader>w |
Save |
<leader>q |
Quit |
<leader>x |
Save and quit |
<leader>e |
Open the built-in file explorer (:Explore) |
<leader>bn / <leader>bp |
Next / previous buffer |
<leader>bd |
Delete buffer |
<leader>P |
Print the current file to the default printer (Linux lp) |
Windows and folds
| Mapping |
Action |
<C-h> <C-j> <C-k> <C-l> |
Move between splits |
<C-Up> <C-Down> <C-Left> <C-Right> |
Resize the current split |
<leader>v / <leader>s |
Vertical / horizontal split |
<leader>f / <leader>F |
Toggle fold / toggle fold recursively |
Toggles
| Mapping |
Action |
<leader>n |
Toggle line numbers |
<leader>r |
Toggle relative line numbers |
<leader>pp |
Toggle paste mode |
<leader>c |
Toggle copy mode (hide line numbers, listchars and signs) |
<leader>bg |
Toggle dark/light background |
Running code
| Mapping |
Action |
<F5> |
Save and run the current file with python3 |
<F6> |
Run the current file based on its filetype (python, javascript, sh, ruby, perl) |
Plugins
| Mapping |
Action |
<C-t> |
Toggle NERDTree |
<F8> |
Toggle Tagbar |
Auto-closing pairs (insert mode)
Typing ', `, ", (, [ or { inserts the matching pair. Suffixes change
the result:
| Typed |
Result |
( |
() with the cursor inside |
(; |
(); with the cursor inside |
(, |
(), with the cursor inside |
(<Tab> |
() with the cursor after the pair |
(<CR> |
Multi-line block with the cursor on a blank middle line |
Because these mappings share prefixes, Vim waits timeoutlen (500 ms) after each
opening character. Use <leader>pp before pasting into a terminal Vim, otherwise
pasted brackets and quotes are duplicated.
📋 Copying text
Whitespace dots (·), end-of-line marks (¬) and line numbers are drawn on
screen only — they are never part of the buffer, so Vim's own yank never
includes them. If they show up when you paste, the selection was made by the
terminal rather than by Vim.
- Select with the mouse and press
y. mouse=a is enabled, so dragging
creates a Vim visual selection and y copies the real text to the system
clipboard. This is the clean path.
- Shift-drag bypasses Vim and uses the terminal's own selection, which copies
whatever is painted on screen. Press
<leader>c first to hide the line
numbers, listchars and sign column, and the terminal selection comes out clean
too. Press it again to restore.
Yanking a whole line with V or yy is linewise and carries a trailing newline
with it. To copy just the text, use ^vg_y (first to last non-blank character)
or y$ from the start of the line.
Clipboard integration needs a Vim built with +clipboard — check with
vim --version | grep clipboard. If it shows -clipboard, install a full build
(vim-gtk3 on Debian/Ubuntu) or use <leader>c plus terminal copy.
🧩 Commands
| Command |
Action |
:UpdatePluginsNow |
Force a plugin update, ignoring the 7-day interval |
🤖 Auto-Features
- Automatic plugin installation on first run
- Periodic plugin updates (every 7 days, see
g:plug_update_interval)
- Auto-creation of necessary directories (
~/.vim/backup, ~/.vim/swap, ~/.vim/undo)
- Trailing whitespace removal on save — skipped for
markdown, diff, gitcommit,
gitsendemail and mail, where trailing whitespace is meaningful
- ALE applies its configured fixers on save (
eslint --fix for JavaScript)
- Cursor position restoration when reopening files
- NERDTree opens automatically when Vim starts without a file argument
🛠️ Customization
Edit the configuration files directly or override settings in your ~/.vimrc after sourcing these files.
Useful knobs:
g:plug_update_interval (plugins.vim) - seconds between automatic plugin updates
g:plug_auto_update - set to 0 in your ~/.vimrc to skip the update check on
startup and update only via :UpdatePluginsNow
g:ale_fix_on_save - set to 0 to stop ALE rewriting files on save
mapleader (config.vim) - the leader key, currently ,
📄 License
MIT License