vimrc配置文件

重新加载配置

: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>

相关推荐

  1. vimrc配置文件

    2024-01-18 04:02:01       51 阅读
  2. .vimrc文件的语句语法

    2024-01-18 04:02:01       32 阅读
  3. Idea vimrc

    2024-01-18 04:02:01       51 阅读
  4. RT-1配置文件

    2024-01-18 04:02:01       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-18 04:02:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-18 04:02:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-18 04:02:01       82 阅读
  4. Python语言-面向对象

    2024-01-18 04:02:01       91 阅读

热门阅读

  1. Oracle JDK 8 中的 computeIfAbsent 方法及实践

    2024-01-18 04:02:01       46 阅读
  2. 设计模式之行为型模式

    2024-01-18 04:02:01       40 阅读
  3. Codeforces Round 920 (Div. 3)

    2024-01-18 04:02:01       56 阅读
  4. VCG 网格清洗之移除小组件

    2024-01-18 04:02:01       54 阅读
  5. 3、python布尔类型和条件表达式

    2024-01-18 04:02:01       50 阅读
  6. Ubuntu 从零开始配置环境

    2024-01-18 04:02:01       51 阅读
  7. [网络安全]DHCP 部署与安全

    2024-01-18 04:02:01       46 阅读
  8. CSS 高频面试题

    2024-01-18 04:02:01       50 阅读
  9. MetaGPT-打卡day01

    2024-01-18 04:02:01       47 阅读