重新加载配置
: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配置
最后一条命令需要仔细研读文章来源地址https://www.toymoban.com/news/detail-799454.html
" 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>
文章来源:https://www.toymoban.com/news/detail-799454.html
到了这里,关于vimrc配置文件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!