vim编译运行 cpp
vim 只是一个 编辑工具,尽量不要装太多的插件,不然反而变笨重了, 最好只是定义一些自己需要用的快捷键功能
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
|
"" Source your .vimrc
"source ~/.vimrc
"" -- Suggested options --
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
" Do incremental searching.
set incsearch
" Don't use Ex mode, use Q for formatting.
map Q gq
"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t
"" Map \r to the Reformat Code action
"map \r <Action>(ReformatCode)
"" Map <leader>d to start debug
"map <leader>d <Action>(Debug)
"" Map \b to toggle the breakpoint on the current line
"map \b <Action>(ToggleLineBreakpoint)
" Find more examples here: https://jb.gg/share-ideavimrc
" 设置 tab缩进"
set tabstop=4 " 设置Tab长度为4空格
set shiftwidth=4 " 设置自动缩进长度为4空格
set autoindent " 继承前一行的缩进方式,适用于多行注释
set smartindent
set laststatus=2
"显示命令"
set showcmd
" 开启实时搜索
set incsearch
" 搜索时大小写不敏感
set ignorecase
syntax enable
set nu
set showmatch
set timeoutlen=500
set clipboard+=unnamed
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
" 按f 直接进入 行首, t 表示 tail ,到行尾
map f 0
map t $
"J 和 j一样,原来的 vim的命令不习惯
map H 0
map L $
" H 直接跳到行首
map K gg
" shift + l 跳到文件末尾
map J G
set whichwrap=h,l,b,s,<,>,[,]
"关闭讨厌的铃声
set vb t_vb=
imap jk jk
" insert模式下 ee = esc退出
imap ee <Esc>
" insert模式 按 qq = esc
imap qq <Esc>
" normal模式 按 c 转命令模式
nmap c :
nmap [ <PageUp>
nmap ] <PageDown>
" 编译代码命令
func! CompileCodeFile()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
endif
endfunc
func! RunCodeFile()
if &filetype == 'cpp'
exec "!%:r"
endif
endfunc
map <F8> :call CompileCodeFile() <CR>
map <F9> :call RunCodeFile()<CR>
map <F10> :call CompileCodeFile()<CR> :call RunCodeFile()<CR>
" f10 编译且运行 ,f8编译
" 这里只是 定义了 cpp的编译运行,可以自定义其他语言的运行
|