• 我的.vimrc配置


    termux平台下,通过pkg update && pkg upgrade && pkg install vim来获得vim。可是,当我配置.vimrc时发现如果我每在一个平台使用vim都要敲键盘的话,太浪费时间了。毕竟,人生苦短。于是,我将win10、centos平台下编写的配置写下来;以后就复制粘贴就行了。
    在Windows平台下,Full安装默认出现:

    source $VIMRUNTIME/vimrc_example.vim
    
    set diffexpr=MyDiff()
    function MyDiff()
      let opt = '-a --binary '
      if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
      if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
      let arg1 = v:fname_in
      if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
      let arg1 = substitute(arg1, '!', '!', 'g')
      let arg2 = v:fname_new
      if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
      let arg2 = substitute(arg2, '!', '!', 'g')
      let arg3 = v:fname_out
      if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
      let arg3 = substitute(arg3, '!', '!', 'g')
      if $VIMRUNTIME =~ ' '
        if &sh =~ '<cmd'
          if empty(&shellxquote)
            let l:shxq_sav = ''
            set shellxquote&
          endif
          let cmd = '"' . $VIMRUNTIME . 'diff"'
        else
          let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . 'diff"'
        endif
      else
        let cmd = $VIMRUNTIME . 'diff'
      endif
      let cmd = substitute(cmd, '!', '!', 'g')
      silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
      if exists('l:shxq_sav')
        let &shellxquote=l:shxq_sav
      endif
    endfunction
    

    在linux平台下:
    touch ~/.vimrc

    
    ”设置文件编码
    set encoding=utf-8
    set fileencodings=ucs-bom,utf-8,cp936
    set fileencoding=gb2312
    set termencoding=utf-8
    
    syntax on
    "设置颜色
    color darkblue
    set cursorline cursorcolumn
    set incsearch
    set ignorecase
    set smartcase
    "设置保持历史记录10000
    set history=10000
    set nofoldenable
    set confirm
    set backspace=indent,eol,start
    set t_Co=256
    set report=0
    set nowrap
    set scrolloff=5
    set number
    set ruler
    set showmatch
    set showcmd
    set title
    set laststatus=2
    set matchtime=2
    set matchpairs+=<:>
    
    " 设置文件不备份,这里被注释掉;
    "          set nobackup
    "          set noundofile
    "          set noswapfile
    set backupext=.bak
    set backupdir=~/.vim/vim_bak/
    
    set autoindent
    set smartindent
    set tabstop=4
    set softtabstop=4
    set shiftwidth=4
    set smarttab
    set textwidth=120
    set colorcolumn=+1
    
    set autoread
    set autowrite
    
    "Vundle
    set nocompatible
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'scrooloose/nerdtree'
    Plugin 'mattn/calendar-vim'
    Plugin 'godlygeek/tabular'
    Plugin 'plasticboy/vim-markdown'
    Plugin 'suan/vim-instant-markdown'
    Plugin 'lervag/vimtex'
    Plugin 'sirver/ultisnips'
    Plugin 'pboettch/vim-cmake-syntax'
    Plugin 'Valloric/YoucompleteMe'
    Plugin 'kien/ctrlp.vim'
    Plugin 'jiangmiao/auto-pairs'
    Plugin 'EasyGrep'
    Plugin 'scrooloose/syntastic'
    Plugin 'Valloric/ListToggle'
    Plugin 'bling/vim-airline'
    Plugin 'maralla/completor.vim'
    Plugin 'vim-scripts/indentpython.vim'
    Plugin 'nvie/vim-flake8'
    Plugin 'Lokaltog/vim-powerline'
    Plugin 'Yggdroot/indentLine'
    Plugin 'lervag/vimtex'
    Plugin 'tpope/vim-fugitive'
    Plugin 'EditPlus'
    Plugin 'cst'
    Plugin 'Xdebug'
    Plugin 'PyChimp'
    Plugin 'snipMate'
    call vundle#end()
    filetype plugin indent on
    
    "设置日历方面
    let g:calendar_diary="/mnt/c/Users/mydai/diary/"
    let g:calendar_focus_today=1
    
    let g:tex_flavor='latex'
    let g:vimtex_view_method='zathura'
    let g:vimtex_quickfix_mod=0
    set conceallevel=1
    
    " YouCompleteme config:fedora 27 and later:
    "      sudo dnf install cmake gcc g++ make python3-devel
    " Compiling YCM with semantic support for C-family languages through libclang;
    "      cd ~/.vim/bundle/youcompleteme
    "      python3 install.py --clang-completer
    " YCM Configuration notes:
    let g:ycm_min_num_of_chars_for_completion=3
    let g:ycm_python_binary_path='python'
    let g:ycm_seed_identifiers_with_syntax=1
    let g:ycm_autoclose_preview_window_after_completion=1
    let g:ycm_auto_trigger=1
    
    
    " pip3 install jedi
    " 为了Python3的第三方库安装Jedi插件
    " Plugin 'davidhalter/jedi-vim'
    "===============================Jedi==================================
    if has('python3')
    let g:loaded_youcompleteme = 1 " 判断如果是python3的话,就禁用ycmd。
    let g:jedi#force_py_version = 3
    let g:pymode_python = 'python3'
    endif
    "===============================Jedi===================================
    "Note: This option must be set in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
    " Disable AutoComplPop.
    let g:acp_enableAtStartup = 0
    " Use neocomplete.
    let g:neocomplete#enable_at_startup = 1
    " Use smartcase.
    let g:neocomplete#enable_smart_case = 1
    " Set minimum syntax keyword length.
    let g:neocomplete#sources#syntax#min_keyword_length = 3
    
    " Define dictionary.
    let g:neocomplete#sources#dictionary#dictionaries = {
         'default' : '',
         'vimshell' : $HOME.'/.vimshell_hist',
         'scheme' : $HOME.'/.gosh_completions'
             }
    
    " Define keyword.
    if !exists('g:neocomplete#keyword_patterns')
        let g:neocomplete#keyword_patterns = {}
    endif
    let g:neocomplete#keyword_patterns['default'] = 'hw*'
    
    " Plugin key-mappings.
    inoremap <expr><C-g>     neocomplete#undo_completion()
    inoremap <expr><C-l>     neocomplete#complete_common_string()
    
    " Recommended key-mappings.
    " <CR>: close popup and save indent.
    inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
    function! s:my_cr_function()
      return (pumvisible() ? "<C-y>" : "" ) . "<CR>"
      " For no inserting <CR> key.
      "return pumvisible() ? "<C-y>" : "<CR>"
    endfunction
    " <TAB>: completion.
    inoremap <expr><TAB>  pumvisible() ? "<C-n>" : "<TAB>"
    " <C-h>, <BS>: close popup and delete backword char.
    inoremap <expr><C-h> neocomplete#smart_close_popup()."<C-h>"
    inoremap <expr><BS> neocomplete#smart_close_popup()."<C-h>"
    " Close popup by <Space>.
    "inoremap <expr><Space> pumvisible() ? "<C-y>" : "<Space>"
    
    " AutoComplPop like behavior.
    "let g:neocomplete#enable_auto_select = 1
    
    " Shell like behavior(not recommended).
    "set completeopt+=longest
    "let g:neocomplete#enable_auto_select = 1
    "let g:neocomplete#disable_auto_complete = 1
    "inoremap <expr><TAB>  pumvisible() ? "<Down>" : "<C-x><C-u>"
    
    " Enable omni completion.
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
    autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    
    " Enable heavy omni completion.
    if !exists('g:neocomplete#sources#omni#input_patterns')
      let g:neocomplete#sources#omni#input_patterns = {}
    endif
    "let g:neocomplete#sources#omni#input_patterns.php = '[^. 	]->hw*|hw*::'
    "let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *	]\%(.|->)'
    "let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *	]\%(.|->)|hw*::'
    
    " For perlomni.vim setting.
    " https://github.com/c9s/perlomni.vim
    let g:neocomplete#sources#omni#input_patterns.perl = 'hw*->hw*|hw*::'
    
    "vim打开文件,光标定位到上次退出的位置;
    if has("autocmd")
    	autocmd BufReadPost *
    	 if line("'"") > 0 && line("'"") <= line("$") |
    	   exe "normal g`"" |
    	 endif
      endif"`'")"'")
    
    

    写完配置文件后,就要git了:

    mkdir ~/.vim/
    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    

    随后进入 vim:
    执行:
    PluginInstall

    git相关知识,再次写一下:
    Powershell平台下posh-git:

    Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force
    
    Install-Module posh-git -Scope CurrentUser -Force
    Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force  # Newer beta version with PowerShell Core support(这个没下载,不使用)
    
    

    Git in Bash(哎,人生苦短,直接截图):

  • 相关阅读:
    box-shadow使用指南
    chrome的input默认样式黄色背景以及选中加粗的边框处理
    Spring AOP执行方法
    Spring JDBC主从数据库访问配置
    JS 命名冲突
    Data truncation: Truncated incorrect DOUBLE value 解决方案
    MySQL DATE_ADD() 函数
    Codeforces Round #340 (Div. 2)
    2020牛客寒假算法基础集训营3
    Codeforces Round #377 (Div. 2)
  • 原文地址:https://www.cnblogs.com/ldh1112/p/11001780.html
Copyright © 2020-2023  润新知