-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
137 lines (113 loc) · 3.25 KB
/
Copy pathvimrc
File metadata and controls
137 lines (113 loc) · 3.25 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
"tab 不显示全路径
function! Tabline() abort
let l:line = ''
let l:current = tabpagenr()
for l:i in range(1, tabpagenr('$'))
if l:i == l:current
let l:line .= '%#TabLineSel#'
else
let l:line .= '%#TabLine#'
endif
let l:label = fnamemodify(
\ bufname(tabpagebuflist(l:i)[tabpagewinnr(l:i) - 1]),
\ ':t'
\ )
let l:line .= '%' . i . 'T' " Starts mouse click target region.
let l:line .= ' ' . l:label . ' '
endfor
let l:line .= '%#TabLineFill#'
let l:line .= '%T' " Ends mouse click target region(s).
return l:line
endfunction
set tabline=%!Tabline()
set number
syntax on
set autoindent
set autoread
"set cursorline " 高亮显示当前行
set showmatch " 显示匹配
set ruler " 显示标尺,在右下角显示光标位置
"相对行号
set relativenumber
map <F3> :set norelativenumber nonumber<CR>
map <F3><F3> :set relativenumber<CR>
"总是显示标价页
set showtabline=2
set paste
map <F2> gt<CR>
map <F1> gT<CR>
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
set showmatch
set hlsearch
set incsearch
set autochdir
set wildmenu
set backspace=indent,eol,start
set encoding=utf-8
set autoindent
autocmd BufNewFile *.py exec ":call SetPyTitle()"
autocmd BufNewFile *.sh exec ":call SetShTitle()"
func SetPyTitle()
call setline(1, "\# -*- coding: utf-8 -*-")
call setline(2, "\#! /3rd/anaconda3/bin/ipython")
call setline(3, "\"\"\"")
call setline(4, "Author : %AUTHOR% @ firebolt")
call setline(5, "Created Time : ".strftime("%Y-%m-%d %H:%M:%S"))
call setline(6, "Description : <Why this script>")
call setline(7, "\"\"\"")
call setline(8, "")
endfunc
func SetShTitle()
call setline(1, "\#! /usr/bin/bash")
call setline(2, "\# Author : %AUTHOR% @ firebolt")
call setline(3, "\# Created Time : ".strftime("%Y-%m-%d %H:%M:%S"))
call setline(4, "\# Description : <Why this script>")
call setline(5, "")
endfunc
" 自动将光标移动到文件末尾
autocmd BufNewfile * normal G
"新窗口在下方和右方打开
set splitbelow
set splitright
"切换窗口时不需要w键
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
""""""""""""""""一键运行代码""""""""""""""""""""
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
exec "!time sh %"
elseif &filetype == 'python'
exec "!time ipython %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
exec "!time go run %"
elseif &filetype == 'markdown'
exec "!pandoc % --mathjax -o index.html"
else
exec "!sh setup.sh"
endif
endfunc
map <F6> :call CompileRunGcc1()<CR>
func! CompileRunGcc1()
exec "w"
if &filetype == 'python'
exec "!time ipython -m ipdb %"
endif
endfunc