Skip to content

Instantly share code, notes, and snippets.

@ajaxray
Last active November 22, 2025 14:50
Show Gist options
  • Select an option

  • Save ajaxray/f40c5efadec38b3301e475cd2f63b336 to your computer and use it in GitHub Desktop.

Select an option

Save ajaxray/f40c5efadec38b3301e475cd2f63b336 to your computer and use it in GitHub Desktop.
My VIM config (.vimrc) file
set nocompatible
set ff=unix
set number
set ruler
set visualbell
set cursorline
set encoding=utf-8
filetype plugin indent on
syntax on
let mapleader=","
" Whitespace
set nowrap
set textwidth=79
set formatoptions=tcqrn1
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set noshiftround
" cursor motion
set scrolloff=3
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
" Rendering
set ttyfast
" Status bar
set laststatus=2
set showmode
set showcmd
" Searching
vnoremap <expr> // 'y/\V'.escape(@",'\').'<CR>'
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
map <leader>c :let @/=''<cr> " clear search
" Visualize tabs and newlines
set listchars=tab:▸\ ,eol:¬
map <leader>t :set list!<CR> " Toggle tabs and EOL
" Folding
set foldenable " enable folding
set foldmethod=indent " fold based on indent level
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
" space open/closes folds
nnoremap <leader>f za
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" NVim related
if !has('nvim')
set ttymouse=xterm2
endif
if exists(':tnoremap')
tnoremap <Esc> <C-\><C-n>
endif
" Settings for plugins
let g:NERDTreeNodeDelimiter = "\u00a0"
set runtimepath^=~/.vim/bundle/ctrlp.vim

@ajaxray's .vimrc config

Check this reference guide for further details.

General Settings

Setting Description
set nocompatible Disables legacy Vi compatibility, unlocks full Vim features.
set ff=unix Uses Unix-style line endings (LF).
set encoding=utf-8 Sets global text encoding to UTF-8 for multilingual/text handling.
filetype plugin indent on Enables filetype detection, plugin loading, and smart indentation.
syntax on Turns on syntax highlighting.

Whitespace & Formatting

Setting Description
set nowrap Prevents soft-wrapping of long lines.
set textwidth=79 Auto-wraps text at 79 chars (code/style preference).
set formatoptions=tcqrn1 Controls paragraph formatting and auto-wrapping: e.g. auto-wrap comments, join lines, etc.
set tabstop=4 Sets tab width to 4 spaces.
set shiftwidth=4 Sets indentation for >>, <<, and auto-indent.
set softtabstop=4 Soft tab key works as 4 spaces.
set expandtab Converts typed tabs to spaces.
set noshiftround Prevents rounding indentation to multiples of shiftwidth.

Cursor Motion & Navigation

Setting Description
set scrolloff=3 Leaves 3 lines visible around the cursor while scrolling.
set backspace=indent,eol,start Makes backspace work over indents, EOLs, and at insert start.
set matchpairs+=<:> Adds < and > for pair jump navigation with %.
nnoremap B ^ Remaps B to go to start of line.
nnoremap E $ Remaps E to go to end of line.

Rendering & Performance

Setting Description
set ttyfast Tells Vim terminal is fast, turning on snappier redraw.
set cursorline Highlights the current cursor row.

Status Bar & UI

Setting Description
set number Shows line numbers.
set ruler Shows current position (row/col) on status bar.
set laststatus=2 Always displays status line.
set showmode Displays current editing mode in status bar.
set showcmd Shows partial typed command in lower right.

Searching & Highlighting

Setting Description
vnoremap <expr> // 'y/\\V'.escape(@", '\\').'<CR>' Visually select then press // to search for the exact selection.
set hlsearch Highlights all instances of the last search.
set incsearch Matches candidates as you type your search pattern.
set ignorecase Ignores case in search patterns.
set smartcase Makes search case-sensitive if you use uppercase letters.
set showmatch Briefly jumps to matching parenthesis when typing one.
map <leader>c :let @/=''<cr> <leader>c (,c) clears highlighted search.

Visualizing Whitespace

Setting Description
set listchars=tab:▸\\ ,eol:¬ Shows tab and EOL characters visually.
map <leader>t :set list!<CR> Toggles visible whitespace marks.

Code Folding

Setting Description
set foldenable Turns on folding.
set foldmethod=indent Uses indentation to detect folds.
set foldlevelstart=10 Opens most folds by default (nesting up to level 10).
set foldnestmax=10 Maximum allowed fold nesting.
nnoremap <leader>f za Toggles fold at cursor with <leader>f (,f).

Neovim & Terminal Support

Setting Description
if !has('nvim') / set ttymouse=xterm2 / endif Improve mouse support on non-Neovim Vim.
if exists(':tnoremap') / tnoremap <Esc> <C-\><C-n> / endif In terminal buffers, Esc returns to normal mode in Neovim.

Plugin & Runtime Settings

Setting Description
let g:NERDTreeNodeDelimiter = "\u00a0" Sets NERDTree node delimiter for better layout.
set runtimepath^=~/.vim/bundle/ctrlp.vim Adds ctrlp.vim plugin path.

Mappings & Leader Key

Setting Description
let mapleader="," Sets leader key to , for shortcut mappings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment