-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc_basic.vim
More file actions
178 lines (150 loc) · 3.34 KB
/
Copy pathvimrc_basic.vim
File metadata and controls
178 lines (150 loc) · 3.34 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
" vim:fdm=marker
" remap leader using ',' {{{
let mapleader = ','
let g:mapleader = ','
" }}}
" treat long line as break lines {{{
map j gj
map k gk
" }}}
" map <SPACE> to pageup and pagedown {{{
map <space> <c-f>
map <c-space> <c-b>
" }}}
" status line, if no plugin powerup {{{
" always show statusline
set laststatus=2
" format
"set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" }}}
" hide tool bar {{{
"set guioptions-=m
"set guioptions-=T
"set guioptions-=L
"set guioptions-=r
"set guioptions-=b
set go=
" launch maximize window
if has('gui_running')
if has('win32')
autocmd GUIEnter * simalt ~x
endif
endif
" }}}
" set working dir as current file's dir {{{
set bsdir=buffer
"set autochdir
" }}}
" set encoding {{{
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
let &termencoding=&encoding
set ambiwidth=double
" }}}
" source menu stuffs {{{
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim
" }}}
" disable temp files {{{
set nobackup
set noswapfile
set history=1024
" }}}
" search options: ignore case {{{
set ignorecase
set smartcase
set incsearch
set hlsearch
set noerrorbells
" }}}
" match and line style {{{
set wildmenu
" ignore files and folders
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.idea/*,*.o,*~
" always show line number
set number
set ruler
set cursorline
"don's redraw when running macros
set lazyredraw
" }}}
" setting indents {{{
"set noautoindent
set cindent
setlocal cinoptions=g0
set smartindent
set showmatch
" set >> and <<, move 4 spaces
set smarttab
set shiftwidth=4
set tabstop=4
set expandtab
" and some different options based on filetype
autocmd BufNewFile, BufRead *.html, *.htm, *.css, *.js set noexpandtab tabstop=2 shiftwidth=2
"autocmd BufNewFile, BufRead *.py set nosmarttab
set foldmethod=indent
set foldnestmax=3
set nofoldenable
" set 10 lines after cursorline
set so=10
" }}}
" share the clipboard with windows {{{
if has('win32')
set clipboard+=unnamed
endif
" }}}
" startup option {{{
set shortmess=atl
set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,slash,unix,resize
" }}}
" persistent undo {{{
set undofile
set undodir=$VIM/\_undodir
set undolevels=1000
" }}}
" color basic option {{{
syntax on
set background=dark
" }}}
" run file depend on the script type {{{
function! Run()
let type = b:current_syntax
if type == "python"
exec "!python -B %"
elseif type == "dosbatch"
exec "!%"
endif
endfunction
nmap <F5> :call Run()<cr>
" }}}
" zeal mapping (not active now) {{{
function! LookupZeal()
"let type = b:current_syntax
exec "!zeal.exe --query open"
endfunction
"nnoremap <Leader>z :call LookupZeal()<CR><CR>
" }}}
" some mapping learned from dotvim {{{
" aux functions {{{
function! Preserve(command) "{{{
" preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
execute a:command
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction "}}}
function! StripTrailingWhitespace() "{{{
call Preserve("%s/\\s\\+$//e")
endfunction "}}}
"}}}
set backspace=indent,eol,start
nmap <leader>fef :call Preserve("normal gg=G")<CR>
nmap <leader>f$ :call StripTrailingWhitespace()<CR>
vmap <leader>s :sort<CR>
inoremap <C-h> <left>
inoremap <C-l> <right>
" }}}