-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc-linux
More file actions
122 lines (103 loc) · 2.44 KB
/
Copy pathvimrc-linux
File metadata and controls
122 lines (103 loc) · 2.44 KB
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
" SelfDefined remapping keys ---------- {{{
" this line just for fix some bugs on python3 imp module problem
if has("python3")
silent! python3 1
endif
" make edit vimrc file more confortable
let mapleader = "-"
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
" make enter and space to insert blank
nnoremap <CR> o<Esc>
nnoremap <Space> i<Space><Esc>l
" disable record function and turn it to quit program
function! QuitProgram()
" the file has not been modified, quit directly
if &modified == 0
:q
endif
" the file has been modifed, ask before quit
let choice = confirm("Quit?", "&No\n&Save\n&Discard")
if choice == 1
elseif choice == 2
:wq
else
:q!
endif
endfunction
nnoremap q :call QuitProgram()<Esc>
" make some abbreviations
iabbrev @@ p1usj4de@163.com
iabbrev ccopy Copyright 2018 Hanlin Yang, all rights reserved.
" remap the H, L, and make delete more easier
nnoremap H 0
nnoremap L $
nnoremap dH d0
nnoremap dL d$
" make <Esc> more confortable
inoremap jk <Esc>
augroup AutoInsertParenthesis
autocmd!
inoremap { {}<Left>
inoremap {{ {
inoremap {} {}
inoremap [ []<Left>
inoremap [[ [
inoremap [] []
inoremap ( ()<Left>
inoremap (( (
inoremap () ()
inoremap < <><Left>
inoremap << <
inoremap <> <>
inoremap " ""<Left>
inoremap "" "
inoremap ' ''<Left>
inoremap '' '
vnoremap ( c()<Esc>P
vnoremap " c""<Esc>P
vnoremap ' c''<Esc>P
vnoremap < c<><Esc>P
augroup end
augroup SimpleCommentTool
autocmd!
autocmd FileType python nnoremap " 0i#<Esc>0
autocmd FileType shell nnoremap " 0i"<Esc>0
autocmd FileType c,cpp nnoremap " 0i//<Esc>0
autocmd FileType vim nnoremap " 0i"<Esc>0
augroup end
" }}}
" Basic vim file settings ---------- {{{
" use gui color-set scheme
set encoding=utf-8
set backspace=indent,eol,start " more powerful backspacing
hi clear
set shortmess=atI
set showcmd
set number
set is
set autoread
set autoindent
syntax on
set hlsearch
highlight Search guibg=red
set wildmenu
set wildmode=full
set history=200
" to be consistent with PEP 8
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
augroup HighlightInsertionLine
autocmd!
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul
augroup end
augroup SetProgrammingComment
autocmd!
autocmd FileType python,shell setlocal commentstring=#\ %s
autocmd FileType c,cpp,java setlocal commentstring=//\ %s
augroup end
augroup SetVimFoldMethod
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}