-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
135 lines (99 loc) · 3.03 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
" VIM Configuration File
" Description: VIM config mainly for C/C++ development
" Author: Jiaming Yi
" Automatic installation plugins
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugins')
" Declare the list of plugins.
" Plug 'vim-scripts/c.vim'
Plug 'airblade/vim-gitgutter'
Plug 'itchyny/lightline.vim'
if has('unix')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
endif
if has('macunix')
Plug '/usr/local/opt/fzf'
endif
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
" List ends here. Plugins become visible to Vim after this call.
call plug#end()
" autoload plugins for targeted file type
filetype plugin on
" ignorecase when search, but when uppercase is detected, switch to case sensitive search
set ignorecase
set smartcase
" set status line always on
set laststatus=2
" disable automatic comment insertion
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" set working directory at startup
" cd ~/nessus-plugins/
" open NERDTree when VIM starts
" autocmd vimenter * NERDTree
" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" spell check off
" autocmd VimEnter * set nospell
" set file encoding
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" change to file's directory when opening files
" set autochdir
" turn off beep
set noerrorbells
set novisualbell
set t_vb=
autocmd! GUIEnter * set vb t_vb=
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
" disable vi compatibility (emulation of old bugs)
set nocompatible
" use indentation of previous line
set autoindent
" use intelligent indentation for C
set smartindent
" configure tabwidth and insert spaces instead of tabs
set tabstop=2 " tab width is 2 spaces
set shiftwidth=2 " indent also with 2 spaces
set expandtab " expand tabs to spaces
" wrap lines at 120 chars. 80 is somewhat antiquated with nowadays displays.
set textwidth=120
" turn syntax highlighting on
set t_Co=256
syntax on
" set colorscheme
colorscheme murphy
" turn line numbers on
set number
" highlight matching braces
set showmatch
" highlight all matches
set hlsearch
" clear last search highlight
nnoremap <F9> :noh<return>
" intelligent comments
set comments=sl:/*,mb:\ *,elx:\ */
" Enhanced keyboard mappings
"
" F2 save and exit the file
inoremap <F2> <Esc>:wq<CR>
nnoremap <F2> <Esc>:wq<CR>
" F3 save the file
inoremap <F3> <Esc>:w<CR>
nnoremap <F3> <Esc>:w<CR>
" F4 enable/disable line number
nnoremap <F4> :set invnumber<CR>
" F5 to create fold, F6/F7 to open/close fold
nnoremap <F5> zfa{
nnoremap <F6> zo
nnoremap <F7> zc
" open NERDTree window
nnoremap <F12> :NERDTreeToggle<CR>