-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
126 lines (105 loc) · 3.5 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
set nocompatible "不要使用vi的键盘模式,而是vim自己的(命令模式下TAB补全)
filetype plugin on "载入文件类型插件
filetype off "侦测文件类型
syntax on "enable colors
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
call vundle#end()
filetype plugin indent on
"display settings
"""""""""""""""""""""""""""""""""""""""""
colo desert
set bg=dark
set nu "show cursor position in status bar
set ruler "Always show current position
set showcmd "show typed command in status bar
set showmode "Show editing mode
set showmatch "高亮显示匹配的括号
set title "show file in titlebar
set wildmenu "Show possible command when perssing<TAB>
set scrolloff=3 "光标移到buffer的顶部和底部保存3行距离
"set laststatus=2 " 始终显示状态行
set stl=\ [File]\ %F%m%r%h%y[%{&fileformat},%{&fileencoding}]\ %w\ \ [PWD]\ %r%{GetPWD()}%h\ %=\ [Line]%l/%L\ %=\[%P] "设置状态栏的信息
func! GetPWD()
return substitute(getcwd(), "", "", "g")
endf"
"editor settings
"""""""""""""""""""""""""""""""""""""""""
set incsearch "Search as you type
set ignorecase "Ignore case when searching
set hlsearch "Hightlight search things
set smartindent "smart auto indenting
set smarttab "smart tab handling for indenting
"set magic "change the way backslashes are used in search patterns
set matchpairs=(:),{:},[:],<:>
set autoread "Set to auto read when a file is changed from the outside
set nobackup "Turn backup off,no backup ~ files.
set foldenable
set keywordprg=sdcv "sdcv 按K翻译当前单词
set nolinebreak
setlocal noswapfile "no swapfile
"定义W命令,允许以root权限保存文件
command W w !sudo tee % > /dev/null
"misc settings
"""""""""""""""""""""""""""""""""""""""""
set hidden "remember undo after quitting
set history=400 "Sets how many lines of history VIM to remember
set mouse=a
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,gbk,gb2312,gb18030,cp936
set shiftwidth=4
set tabstop=4
set softtabstop=4 "replay <Tab>with 4 blank space
"set expandtab
runtime! ftplugin/man.vim "Man 3 ctime , \K
if has("autocmd")
"打开文件时,总是跳到退出之前的光标处
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
autocmd FileType python,c,cpp,javascript setlocal ts=4 sts=4 sw=4 expandtab
"将指定文件的换行符转换成 UNIX 格式
autocmd FileType php,javascript,html,css,python,vim,vimwiki set ff=unix
endif
"Bash like
nmap <C-A> <Home>
imap <C-A> <Home>
nmap <C-E> <End>
imap <C-E> <End>
"Move in insert mode
imap <M-k> <Up>
imap <M-j> <Down>
imap <M-h> <Left>
imap <M-l> <Right>
"Tab navigation
nmap <C-t> :tabnew<CR>
nmap <C-p> :tabprevious<CR>
nmap <C-n> :tabnext<CR>
nmap <C-k> :tabclose<CR>
nmap <C-Tab> :tabnext<CR>
"折叠的键映射
noremap <M-z> zc
noremap <M-x> zO
inoremap <M-z> <C-o>zc
inoremap <M-x> <C-o>zO
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc
map <F6> :call CRPython()<CR>
imap <F6> <ESC> :call CRPython()<CR>
vmap <F6> <ESC> :call CRPython()<CR>
func! CRPython()
exec "w"
exec "!clear"
exec "!python %"
endfunc
"plugin setting
"""""""""""""""""""""""""""""""""""""""""
"NERDTree""""""
map <F4> :NERDTree<CR>