本文主要是介绍vimrc配置文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
- 重新加载配置
- 基本配置
- 配置命令
- 配置撤销
- 交换文件相关配置
- 窗口切换快捷键绑定
- 关闭缓冲区而不关闭窗口
- 代码折叠
- 自动补全的文件名菜单
- NERDTree配置
- Vinegar插件配置
- 解决右键不能粘贴的问题
- 搜索相关配合
- 粘贴板设置
- 先导键配置
- ctrlP插件配置
重新加载配置
:source $MYVIMRC
基本配置
syntax on " Enable syntax highlighting.
filetype plugin indent on " Enable file type based indentation.set autoindent " Respect indentation when starting a new line.
set expandtab " Expand tabs to spaces. Essential in Python.
set tabstop=4 " Number of spaces tab is counted for.
set shiftwidth=4 " Number of spaces to use for autoindent.set backspace=2 " Fix backspace behavior on most terminals.colorscheme murphy " Change a colorscheme.set number
配置命令
命令 | 说明 | 注释 |
---|---|---|
:set autoindent | 先尝试再配置 | 再写入配置文件 |
:set tabstop? | 显示当前值 | |
配置撤销
set undofile
#条件判断错误
"if !isdirectory("$HOME/.vim/undodir")
"" call mkdir("$HOME/.vim/undodir","p")
"endif
set undodir=$HOME/.vim/undodir
交换文件相关配置
"配置交换文件""存放到统一目录"
set directory=$HOME/.vim/swap//"关闭交换文件"
set noswapfile
窗口切换快捷键绑定
" Navigate windows with <Ctrl-hjkl> instead of <Ctrl-w> followed by hjkl.
noremap <c-h> <c-w><c-h>
noremap <c-j> <c-w><c-j>
noremap <c-k> <c-w><c-k>
noremap <c-l> <c-w><c-l>
关闭缓冲区而不关闭窗口
#工作不正常
" 关闭缓冲区而不关闭窗口
command! Bd :bp | :sp | :bn | :bd
"bp buffer previous;sp split;bn buffer next;bd buffer delete
代码折叠
set foldmethod=indent " Indentation-based folding.
"manual 手动折叠"
"indent"
"expr"
"marker"
"syntax"
"diff"set foldcolumn=1 "折叠列指示,0-12
"打开文件时,所有折叠打开"
autocmd BufRead * normal zR
自动补全的文件名菜单
set wildmenu " Enable enhanced tab autocomplete."
"第一次补全为最长的匹配字符串,第二次遍历"
set wildmode=list:longest,full " Complete till longest string, then open menu.
NERDTree配置
最后一条命令需要仔细研读
" Plugin-related settings below are commented out. Uncomment them to enable
" the plugin functionality once you download the plugins.let NERDTreeShowBookmarks = 1 " Display bookmarks on startup.
autocmd VimEnter * NERDTree " Enable NERDTree on Vim startup.
" Autoclose NERDTree if it's the only open window left.
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") &&\ b:NERDTree.isTabTree()) | q | endif
Vinegar插件配置
"为了避免NERDTree取代Netrw(-键可用)"
let NERDTreeHijackNetrw =0
#不起作用
解决右键不能粘贴的问题
if has(‘mouse’)
set mouse-=a
endif
搜索相关配合
set hlsearch " Highlight search results.
set incsearch " Search as you type.
粘贴板设置
set clipboard=unnamed,unnamedplus " Copy into system (*, +) registers.
"不起作用"
先导键配置
" Map the leader key to
" 先导键应该定义在.vimrc文件中使用先导键之前,因为新定义的先导键在定义后生效"
let mapleader = "\<space>"
"mapleader变量中不含特殊字符,需要反斜杠转义,因为单引号只能存储字面量字符串,需要双引号包括"
" Save a file with leader-w.
noremap <leader>w :w<cr>
" toggle nerdtree"
noremap <leader>n :NERDTreeToggle<cr>
ctrlP插件配置
" Set CtrlP working directory to a repository root (with a
" fallback to current directory).
let g:ctrlp_working_path_mode = 'ra'
"let g:ctrlp_working_path_mode = 'c'" 用先导键重新映射CtrlP的行为"
"noremap <leader>p :CtrlP<cr>
"noremap <leader>b :CtrlPBuffer<cr>
"noremap <leader>m :CtrlPMRU<cr>
这篇关于vimrc配置文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!