Skip to content

Instantly share code, notes, and snippets.

@hongshanli23
Created February 17, 2020 23:04
Show Gist options
  • Select an option

  • Save hongshanli23/ddd34c81ffb049e11b4f6e0b0f3498dd to your computer and use it in GitHub Desktop.

Select an option

Save hongshanli23/ddd34c81ffb049e11b4f6e0b0f3498dd to your computer and use it in GitHub Desktop.
my vimrc
" source:
" https://dougblack.io/words/a-good-vimrc.html
set nocompatible
syntax enable
set tabstop=2 " number of visual spaces per tab
set softtabstop=2 " number of spaces in tab when editing
set expandtab " tab are spaces
set number " show line numbers
set relativenumber
set showcmd " show command in bottom bar
set cmdheight=2 " command prompt height is 1 line
" set cursorline " highlight current line
" -----------------------------------
" turn on filetype detection and allows loading of language specific
" indentation files. For example, python indentation file in
" .vim/indent/python.vim get loaded when a *.py file is loaded
" filetype indent off " load filetype-sp
" ------------------------------------
" visual autocomplete of for command menu
" for example, :e <TAB> provides a graphical menu
" of all files in the current dir to cycle through
set wildmenu
" ------------------------------------
" highlight matching, for example, [{()}]
set showmatch
" ------------------------------------
" search as charaters are entered
"set incsearch
" highlight matchs
set hlsearch
" Fold code
set foldmethod=indent
" keybinding to clear highlight
nnoremap <leader><space> :nohlsearch<CR>
" Movement ----------------------------
" move to the beginning / end of line
" n at the begining indicate normal mode
"nnoremap b ^
"nnoremap e $
" disable ^ $
" nnoremap $ <nop>
" nnoremap ^ <nop>
" highlight last inserted text
" nnoremap jv `[v`]
" edit vimrc and load vimrc binding
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
" maps in insert mode ------------------------
" Switch off all auto-indenting
set nocindent
set nosmartindent
set noautoindent
set indentexpr=
filetype indent off
filetype plugin indent off
" plugins
" autocommand
set shiftwidth=4
set softtabstop=4
set expandtab
" NERDTree --------------------
" Open nerdtree
map <C-n> :NERDTree<CR>
" toggle btw nerdtree and buffer
map <C-\> :NERDTreeToggle<CR>
" runtime path
set runtimepath^=~/.vim/pack/
function! ToggleIndentGuides()
if exists('b:indent_guides')
call matchdelete(b:indent_guides)
unlet b:indent_guides
else
let pos = range(1, &l:textwidth, &l:shiftwidth)
call map(pos, '"\\%" . v:val . "v"')
let pat = '\%(\_^\s*\)\@<=\%(' . join(pos, '\|') . '\)\s'
let b:indent_guides = matchadd('', pat)
endif
endfunction
" sensible.vim - Defaults everyone can agree on
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 1.2
if exists('g:loaded_sensible') || &compatible
finish
else
let g:loaded_sensible = 'yes'
endif
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
" Use :help 'option' to see the documentation for the given option.
set autoindent
set backspace=indent,eol,start
set complete-=i
set smarttab
set nrformats-=octal
if !has('nvim') && &ttimeoutlen == -1
set ttimeout
set ttimeoutlen=100
endif
set incsearch
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
set laststatus=2
set ruler
set wildmenu
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
if &encoding ==# 'latin1' && has('gui_running')
set encoding=utf-8
endif
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
if has('path_extra')
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276'))
set shell=/usr/bin/env\ bash
endif
set autoread
if &history < 1000
set history=1000
endif
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
set sessionoptions-=options
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
set t_Co=16
endif
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
inoremap <C-U> <C-G>u<C-U>
" vim:set ft=vim et sw=2:
" concealleve
let g:indentLine_setConceal=1
" tmux binding
let g:tmux_navigator_no_mappings=1
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
command B buffers
command Wq wq
function! Repeat()
let times = input("Count: ")
let char = input("Char: ")
exe ":normal a" . repeat(char, times)
endfunction
imap<C-u> <C-o>:call Repeat() <cr>
let g:indentLine_color_term = 239
let g:indentLine_char = '|'
set conceallevel=1
let g:indentLine_conceallevel=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment