Skip to content

Instantly share code, notes, and snippets.

@trongnghia203
Created April 24, 2019 08:27
Show Gist options
  • Save trongnghia203/7a10b96260b6382df10293da3eb7de28 to your computer and use it in GitHub Desktop.
Save trongnghia203/7a10b96260b6382df10293da3eb7de28 to your computer and use it in GitHub Desktop.
How to custom your vim editor
" edit file:~ vi ~/.vimrc
" base
set nocompatible " vim, not vi
syntax on " syntax highlighting
filetype plugin indent on " try to recognise filetype and load plugins and indent files
" interface
set background=dark " tell vim what the background color looks like
set colorcolumn=120 " show a column at 100 chars
set cursorline " highlight current line
"set laststatus=2 " enable airline on open
set noshowmode " don't show mode as airline already does
set number " show line numbers
set relativenumber " show relative line numbers
set ruler " show current position at bottom
set scrolloff=5 " keep at least 5 lines above/below
set shortmess+=I " disable welcome screen
set showcmd " show any commands
set sidescroll=1 " smoother horizontal scrolling
set sidescrolloff=5 " keep at least 5 lines left/right
set splitbelow " create new splits below
set splitright " create new splits to the right
set termguicolors " enable true colors
set wildmenu " enable wildmenu
set wildmode=longest:full,full " configure wildmenu
" whitespace
set expandtab " use tabs instead of spaces
set nojoinspaces " use one space, not two, after punctuation
set shiftround " shift to next tabstop
set shiftwidth=4 " amount of space used for indentation
set softtabstop=4 " appearance of tabs
set tabstop=4 " use two spaces for tabs
" folding
set foldmethod=indent " fold based on markers
set nofoldenable " disable folds until `zc` or `zM` etc is used
set foldcolumn=3
hi FoldColumn ctermfg=216
hi FoldColumn ctermbg=black
hi Folded ctermfg=216
hi Folded ctermbg=black
au FileType ruby setlocal foldmethod=indent foldnestmax=4 foldlevelstart=1
" text appearance
set list " show invisible characters
" set listchars=tab:>·,trail:·,nbsp:¬ " but only show useful chaaracters
set listchars=tab:>·,trail:·,nbsp:¬ " but only show useful chaaracters
set nowrap " disable line wrapping
" interaction
set backspace=2 " make backspace work like most other apps
set mouse=a " enable mouse support
set mousehide " hide the mouse cursor while typing
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap too
" searching
set hlsearch " highlight search matches
hi Search guibg=LightBlue
set ignorecase " set case insensitive searching
set incsearch " find as you type search
set smartcase " case sensitive searching when not all lowercase
" background processes
set autoread " update file when changed outside of vim
set autoindent " copy indentation from the previous line for new line
set clipboard=unnamed " use native clipboard
"set clipboard+=unnamedplus
set history=200 " store last 200 commands as history
set lazyredraw " no unneeded redraws
set nobackup " don't save backups
set noerrorbells " no error bells please
set noswapfile " no swapfiles
set nowritebackup " don't save a backup while editing
set ttyfast " indicates a fast terminal connection
set undodir=~/.config/nvim/undodir " set undofile location
set undofile " maintain undo history between sessions
set undolevels=1000 " store 1000 undos
" autocmd Filetype html setlocal ts=4 sts=4 sw=4
" autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
" autocmd Filetype javascript setlocal ts=4 sts=4 sw=4
" character encoding
if !&readonly
set fileencoding=utf-8
endif
" Plugins
call plug#begin()
source ~/.vimrc.bundles
" add plugins to &runtimepath
call plug#end()
filetype on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment