-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
137 lines (107 loc) · 3.06 KB
/
Copy path.vimrc
File metadata and controls
137 lines (107 loc) · 3.06 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
syntax on
filetype on
filetype plugin indent on
set nu
set ruler
set showcmd
set nocompatible
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936
set fileencoding=utf-8
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call SetTitle()"
func SetTitle()
if &filetype == 'sh' || &filetype == 'python'
call setline(1, "\#######################################################")
call append(line("."), "\# File Name :".expand("%"))
call append(line(".")+1, "\# Author :ljy")
call append(line(".")+2, "\# Created Time :".strftime("%c"))
call append(line(".")+3, "\#####################################################")
else
call setline(1, "/*******************************************************")
call append(line("."), " >File Name :".expand("%"))
call append(line(".")+1, " >Author :ljy")
call append(line(".")+2, " >Created Time :".strftime("%c"))
call append(line(".")+3, "*****************************************************/")
endif
if &filetype == 'sh'
call append(line(".")+4, "\#!/bin/sh")
call append(line(".")+5, "")
endif
if &filetype == 'python'
call append(line(".")-1, "\#!/usr/bin/python")
call append(line(".")-1, "\# -*- coding:utf-8 -*-")
call append(line(".")+4, "")
endif
if &filetype == 'cpp'
call append(line(".")+4, "")
call append(line(".")+5, "#include <iostream>")
call append(line(".")+6, "using namespace std;")
call append(line(".")+7, "")
endif
if &filetype == 'c'
call append(line(".")+4, "")
call append(line(".")+5, "#include <stdio.h>")
call append(line(".")+6, "")
endif
endfunc
autocmd BufNewFile * normal G
"map <F5> :call CompileRunGcc()<CR>
map <F5> :call CompileRunGcc()
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "! ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
exec "! ./%"
elseif &filetype == 'python'
exec "clear"
exec "!python ./%"
endif
endfunc
map <F8> :call RunGdb() <CR>
func! RunGdb()
exec "w"
exec "!g++ % -g -o %<"
exec "!gdb %<"
endfunc
set cursorline
set completeopt=preview,menu
filetype plugin on
set clipboard=unnamed
set nobackup
set confirm
set autoindent
set cindent
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set hlsearch
set incsearch
set showmatch
set matchtime=1
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
func ClosePair(char)
if getline(".")[col(".")-1] == a:char
return "\<Right>"
else
return a:char
endif
endfunc