vim制作Python3编辑器
安装插件管理插件Vundel
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
用vi编辑~/.vimrc,复制下面代码
保存退出,用vim再次进入,:PluginInstall安装即可
syntax on
set nocompatible " 必须
set backspace=indent,eol,start
filetype off " 关闭自动文件类型检查,必须
" 设置运行时包含 Vundle 的路径和 初始化,必须
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin() " 开始调用 Vundle 进行插件的管理
" 首先必须加载 Vundle 插件
Plugin 'VundleVim/Vundle.vim'
" 在下面编写自己需要用的的插件
"""""""""""""""""""""""""""""""
" Python 代码自动补全提示
Plugin 'davidhalter/jedi-vim'
" 缩进标识
Plugin 'Yggdroot/indentLine'
let g:indentLine_color_term = 239
"let g:indentLine_char='🍉'
"let g:indentLine_concealcursor = 'inc'
"let g:indentLine_conceallevel = 2
Plugin 'MarcWeber/vim-addon-mw-utils'
" 文件名模糊匹配
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
" Optional:
Plugin 'honza/vim-snippets'
" Python 代码规范
Plugin 'tell-k/vim-autopep8'
Plugin 'nvie/vim-flake8'
" 自动括号匹配
Plugin 'jiangmiao/auto-pairs'
" 不同括号显示不同颜色
Plugin 'kien/rainbow_parentheses.vim'
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
" 最多多少个
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
" 打开Vim后自动启用rainbow_parenthsis插件
au VimEnter * RainbowParenthesesToggle
" 同时开启对以下 3 种扩号的多彩色高亮显示
au Syntax * RainbowParenthesesLoadRound " ()
au Syntax * RainbowParenthesesLoadSquare " []
au Syntax * RainbowParenthesesLoadBraces " {}
" 快速注释
Plugin 'preservim/nerdcommenter'
" 所有要使用的插件,必须在下面一行之前
call vundle#end() " 必须的
filetype plugin indent on " 打开文件类型检查,必须的
" 下面是帮助信息
" :PluginList - 列出已经安装且配置好的插件
" :PluginInstall - 安装插件
" :PluginUpdate - 更新现有的插件
" :PluginClean - 清空没有在 .vimrc 文件中配置的插件
""""""""""""""""""""""""""""""""""""
" 把你的非插件的其他设置放在这行后面
" 保存 .vimrc 文件后,配置立刻生效
autocmd! bufwritepost $HOME/.vimrc source %
" 开启自动匹配
set showmatch
"设置按下 Tab 键,实际输入的是空格
set expandtab
"设置 expandtab 后,设置一下按一次 Tab 键输入 4 个空格
set tabstop=4
"set smartindent
"自动缩进时候,缩进 4 个空格
set shiftwidth=4
"总是显示状态栏
set laststatus=2
"显示光标当前位置
set ruler
"表示如果当前文件在 Vim 外被修改且未在 Vim 里面重新载入的话,则自动重新读取。
set autoread
"设置 Vim 窗口标题。
set title
"关闭错误提示的响铃
set noerrorbells
" 基于缩进进行代码折叠
set foldmethod=indent
" 启动 Vim 时关闭折叠
set nofoldenable
" Vim打开文件后,重复使用操作命令 za 可打开或关闭当前折叠;
" zM 用于关闭所有折叠,zR 则用来打开所有折叠。
"设置新建文件时候,自动向文件中添加内容
autocmd BufNewFile *.sh,*.py,*.go exec ":call AutoSetFileHead()"
function! AutoSetFileHead()
"对于 shell 脚本文件 "
if &filetype == 'sh'
call setline(1, "#!/bin/bash")
endif
"对于 python3 文件 "
if &filetype == 'python'
call setline(1, "#!/usr/bin/env python3")
call append(1, "# Author: 西瓜甜🍉")
call append(2, "# Email: shark@126.com")
endif
"对于 golang 文件 "
if &filetype == 'go'
call setline(1, "#!/usr/bin/env go")
call append(1, "# Author: 西瓜甜🍉")
call append(2, "# Email: shark@126.com")
call append(3, "")
call append(4, "package main")
endif
"自动将光标定位到文件末尾"
normal G
" 新建一行
normal o
normal o
endfunc
""""""""""""""""""""""
"Quickly Run
""""""""""""""""""""""
map <F5> :call RunNow()<CR>
func! RunNow()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<
"
elseif &filetype == 'sh'
:!time bash %
elseif &filetype == 'python'
exec "!time python3 %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
" exec "!go build %<"
exec "!time go run %"
endif
endfunc
- 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
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 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
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188