" 基本配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"通用设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set splitbelow "分屏时在右边
set splitright "分屏时在下边
colorscheme evening "启用eveing主题
set lines=35 columns=140 " 窗口大小
let mapleader = "," "定义<leader>键
set nocompatible "设置不兼容原始vi模式
filetype on "设置开启文件类型侦测
filetype plugin on "加载对应文件类型插件
set noeb "关闭错误提示
syntax enable "开启语法高亮功能
syntax on "自动语法高亮
let python_highlight_all=1
set t_Co=256 "开启256色支持
set cmdheight=2 "设置命令行高度
set showcmd "select模式下显示选中的行数
set ruler "总是显示光标的位置
set laststatus=2 "总是显示状态栏
set nu "开启行号显示
set cursorline "高亮显示当前行
set whichwrap+=<,>,h,l "设置光标键跨行
set virtualedit=block,onemore "允许光标出现在最后一个字符的后面
set clipboard=unnamedplus "从Vim复制到剪贴板
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 隐藏GVIM菜单及设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" 窗口大小
set lines=35 columns=140
" 分割出来的窗口位于当前窗口下边/右边
set splitbelow
set splitright
"不显示工具/菜单栏
set guioptions-=T
set guioptions-=m
set guioptions-=L
set guioptions-=r
set guioptions-=b
" 使用内置 tab 样式而不是 gui
set guioptions-=e
set nolist
set guifont=Monospace\ 12
colorscheme evening
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 代码缩进与排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent "设置自动缩进
set cindent "设置使用C/C++语言的自动缩进方式
set cinoptions=g0,:0,N-s,(0 "设置使用C/C++语言的具体缩进方式
set smartindent "智能选择对齐方式
filetype indent on "自适应不同语言的智能缩进
set expandtab "将制表符扩展为空格
set tabstop=4 "设置编辑时制表符所占的空格数
set shiftwidth=4 "设置格式化时制表符占用的空格数
set softtabstop=4 "设置4个空格为制表符
set smarttab "在行和段开始处使用制表符
"set nowrap "禁止折行
set backspace=2 "使用回车键正常处理indent.eol,start等
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"代码折叠
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set foldmethod=syntax "设置基于语法进行代码折叠
"set nofoldenable "关闭代码折叠
"set foldmethod=markder "另一种方法
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 缓存设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup "设置不备份
set noswapfile "禁止生成临时文件
set autoread "文件在vim之外修改过,自动重新载入
set autowrite "设置自动保存
set confirm "在处理未保存或只读文件时,弹出确认
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 编码设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set langmenu=zh_CN.UTF-8
set helplang=cn
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 优化设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"映射 esc 键为 jj
inoremap jj <Esc>
"快速打开vim配置文件:_vimrc
nnoremap <leader>e :e ~/.vimrc<cr>
"刷新配置
nnoremap <leader>r :source $MYVIMRC<cr>
" 插入模式、正常模式按 Ctrl+u 快速转换为大写
inoremap <c-u> <esc>viwUea
nnoremap <c-u> viwUe
"Ctrl+d 复制本行并粘贴到一下行
nnoremap <c-d> yyp
" <leader>+q 快速退出vim
nnoremap <leader>q :q<cr>
inoremap <leader>q <Esc>:q<cr>
"插入模式快速到另一个字符右边,对于配对的符号(如括号)很有用
imap <c-a> <Esc>la
"插入模式移动到下一行
imap <c-d> <Esc>o
"移动到末尾
imap <c-e> <Esc>A
" 添加“空格键”为代码折叠
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
"若打开分割窗口,可快速切换窗口
"快捷键提示:Ctrl+w w 切换窗口; Ctrl+w s 水平分割; Ctrl+w v 竖直分割
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
"buffer change
nnoremap <c-n> :bn<cr>
nnoremap <c-p> :bp<cr>
nnoremap <leader>d :bd<cr>
"自动补全括号
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按F5一键运行python
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F5> :w<cr>:!python3 %<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按F7打开目录树
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F7> :Ex<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" netrw配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:netrw_hide = 1 "设置默认隐藏
let g:netrw_browse_split = 3
let g:netrw_liststyle = 3 " tree 模式显示风格
let g:netrw_banner = 0 " 显示帮助信息
let g:netrw_browse_split = 0 "控制 <CR> 直接在当前窗口打开光标下文件
let g:netrw_winsize = 30 " 占用宽度
let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+' " 需要隐藏的文件
let g:netrw_localrmdir = 'trash' "默认的删除工具使用 trash
let g:netrw_altv = 1 " 控制 v 分裂的窗口位于右边
let g:netrw_preview = 1 " 默认是水平分割, 此项设置使之垂直分割
let g:netrw_alto = 0 " 控制预览窗口位于左侧或右侧, 与 netrw_preview 共同作用
" let g:netrw_chgwin = 2 " 控制按下 <CR> 的新文件在位于屏幕右侧的 2 号窗口打开, Lex 默认会设为 2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"输入法自动切换
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"在退出插入模式时,禁用输入法
autocmd InsertLeave * :silent !fcitx5-remote -c
autocmd BufCreate * :silent !fcitx5-remote -c
autocmd BufEnter * :silent !fcitx5-remote -c
autocmd BufLeave * :silent !fcitx5-remote -c
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"vundle管理插件
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
Plugin 'scrooloose/nerdcommenter'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Chiel92/vim-autoformat'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'iamcco/markdown-preview.nvim'
"Plugin
"'dhruvasagar/vim-table-mode' "此处添加了这个语句,但此插件并不是通过这种方式安装,需要按照github上的安装步骤进行,此处仅记录自己安装了这个插件
Plugin 'ferrine/md-img-paste.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"vim-autoformat插件配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:autoformat_verbosemode=0 "详细模式
let g:autoformat_autoindent = 0
let g:autoformat_retab = 1
let g:autoformat_remove_trailing_spaces = 1
au BufWrite * :Autoformat "保存时自动格式化指定文件类型代码
autocmd BufWrite .sql,.c,.py,.java,*.js :Autoformat "设置发生保存事件时执行格式化
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"MarkdownPreview插件配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F3> :MarkdownPreview<CR> "设置 F3 开启 Markdown 文件预览
let g:mkdp_auto_start = 0 "打开文件后自动弹出, 0 为否
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1 "打开文件后自动弹出, 0 为否
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0 "慢速预览, 修改后退出 insert 模式后方会刷新视图, 1 为是
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0 "如果为1,则别人可以连接你的网络
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0 "开启公网链接, 0 为否
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = '' "指定浏览器, 默认会跟随系统浏览器
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
" disable_filename: if disable filename header for preview page, default: 0
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false,
\ 'disable_filename': 0
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = '' "指定端口, 默认随机端口
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」' "指定浏览器窗口标题, 默认为 Markdown 文件名
" recognized filetypes
" these filetypes will have MarkdownPreview... commands
let g:mkdp_filetypes = ['markdown']
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"YouCompleteMe插件配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_global_ycm_extra_conf='~/.vim/plugged/YouCompleteMe/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0 "关闭语法提示
let g:ycm_complete_in_comments=1 " 补全功能在注释中同样有效
let g:ycm_confirm_extra_conf=0 " 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 标签补全引擎
let g:ycm_min_num_of_chars_for_completion=1 " 从第一个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
let g:ycm_goto_buffer_command = 'horizontal-split' " 跳转打开上下分屏
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"md-img-paste插件配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType markdown nmap <buffer><silent> <leader>p :call mdip#MarkdownClipboardImage()<CR>
" there are some defaults for image directory and image name, you can change them
" let g:mdip_imgdir = 'img'
" let g:mdip_imgname = 'image'
linux下vimrc文件
最新推荐文章于 2024-04-21 07:30:00 发布