Skip to content

Instantly share code, notes, and snippets.

@ysheng26
Last active April 7, 2026 00:51
Show Gist options
  • Select an option

  • Save ysheng26/d7a8f7944bfb9305060acfb894c18eb4 to your computer and use it in GitHub Desktop.

Select an option

Save ysheng26/d7a8f7944bfb9305060acfb894c18eb4 to your computer and use it in GitHub Desktop.
Vanilla vimrc
set nocompatible " be iMproved, required
filetype plugin indent on
" Below is customized settings
let mapleader = ','
let maplocalleader = '\\'
inoremap jk <esc>
nnoremap j gj
nnoremap k gk
nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;
nnoremap <leader>w :w<cr>
nnoremap <leader>q :q<cr>
xnoremap p P
vnoremap <leader>y "+y
" Better indentation
vnoremap < <gv
vnoremap > >gv
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
set termguicolors
set t_Co=256
set background=dark
colorscheme retrobox
set colorcolumn=80
set cmdheight=2
" Remove menu bar and tool bar
set guioptions=
" Always show statusline
set laststatus=2
set statusline=[%n]
set statusline+=%<%f%y%h%m
set statusline+=%h%m%r
set statusline+=\%r%=[%b\ 0x%B]
set statusline+=\ %l\ of\ %L,%c%V
set statusline+=\ Page\ %N
set statusline+=\ %P
set wildmenu
set list
set listchars=tab:>-,trail:~
" Change dir to the first opening file
" and don't auto change dir ever.
cd %:p:h
set noautochdir
" auto read the file when file is changed
set autoread
" Don't redraw the screen when executing macros
set lazyredraw
" disable swap files
set noswapfile
" enable backup files
set backup
" persistant undo
set undofile " Save undo's after file closes
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
" several folder locations setup
set undodir=~/.vim/tmp/undo// " Undo files
set backupdir=~/.vim/tmp/backup// " Backups
set directory=~/.vim/tmp/swap// " Swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), 'p')
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), 'p')
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), 'p')
endif
" Make sure crontab doesn't explode
" http://vim.wikia.com/wiki/Editing_crontab
set backupskip=/tmp/*,/private/tmp/*
" case sensitive settings
set ignorecase
" Set highlight search result
set hlsearch
nnoremap <space> :nohlsearch<cr>
" Set search
set incsearch
" Show relative line numbers
set relativenumber
" Show line numbers
set number
" Syntax highlight setting
syntax enable
syntax on
set maxmempattern=2000000
" Set encoding to utf-8
set encoding=utf-8
" Tab and indent settings
set autoindent
set cindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set expandtab
" Map <c-space> with <c-x><c-o>
inoremap <c-space> <c-x><c-o>
inoremap <c-@> <c-x><c-o>
" Delete spaces after each line
nnoremap <f2> :%s/\s\+$//g <cr> :nohlsearch <cr>
" Map <leader>- and <leader>= to :colder and :cnewer
nnoremap <leader>- :colder<cr>
nnoremap <leader>= :cnewer<cr>
if executable('rg')
set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
set grepformat+=%f:%l:%c:%m
endif
" Manage split screens
nnoremap <leader>1 :only<cr>
nnoremap <leader>2 :split<cr>
nnoremap <leader>3 :vsplit<cr>
set winminheight=0
set winminwidth=0
set splitbelow
set splitright
nnoremap <leader>x <c-w>\|<c-w>_
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
let g:netrw_liststyle = 3
nnoremap <leader>0 :echomsg expand('%:p')<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment