共享一份.vimrc配置文件。
set nocompatible " be iMproved, required
set backspace=indent,eol,start
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
"Plugin 'vim-airline/vim-airline'
"Plugin 'vim-airline/vim-airline-themes'
Plugin 'jiangmiao/auto-pairs'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
"Plugin 'flazz/vim-colorschemes'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'Yggdroot/LeaderF'
Plugin 'majutsushi/tagbar'
"Plugin 'airblade/vim-gitgutter'
"Plugin 'tpope/vim-fugitive'
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"
" 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
let mapleader=";" "将';'设置为leader
set nu
"filetype on "检测文件类型
"filetype indent on "为特定文件类型载入相关缩进文件
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-b> :bp<CR>
nnoremap <C-n> :bn<CR>
" code
set mouse=a
"set tw=4 this line will make shell auto enter...
set et
set smarttab
"set encoding=utf-8
set tabstop=4
set shiftwidth=4
set autoindent
set expandtab
" syntax
syntax enable
" search
set incsearch
set hlsearch
set ic "ignore case
" code jump
nnoremap <F7> <ESC><ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>
set tags=tags;/
set tags+=./tags "add current directory's generated tags file
set tags+=tags,/usr/include/tags,~/.
set cscopequickfix=s-,c-,d-,i-,t-,e- "使用quickfix显示cscope的结果
" theme
syntax on
syntax enable
set t_Co=256
set background=dark
colorscheme molokai
"syntax enable
"set background=dark
"colorscheme solarized
"let g:solarized_termcolors=256
"let g:solarized_termtrans = 1
"let g:solarized_diffmode = "normal"
"let g:solarized_use16 = 1
"file
au BufRead,BufNewFile *.{sh} set filetype=sh
au BufRead,BufNewFile *.{c} set filetype=c
au BufRead,BufNewFILE *.{py} set filetype=python
au BufRead,BufNewFILE *.{java} set filetype=java
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd
au BufRead,BufNewFile *.{go} set filetype=go
au BufRead,BufNewFile *.{js} set filetype=javascript
au BufRead,BufNewFile *.{log} set filetype=log
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call SetTitle()"
func SetTitle()
if &filetype == 'sh'
call setline(1, "\###############################################################")
call append(line(".")+0, " \# Copyright(c) 2005-".strftime("%Y")." TriHappy Technologies Co. Ltd.")
call append(line(".")+1, " \# All right reserved.")
call append(line(".")+2, " \#")
call append(line(".")+3, " \# Filename : ".expand("%"))
call append(line(".")+4, " \# Version : 1.0")
call append(line(".")+5, " \# Abstract : ")
call append(line(".")+6, " \# Author : Adam Ma")
call append(line(".")+7, " \# Created Date : ".strftime("%Y.%m.%d"))
call append(line(".")+8, " \#")
call append(line(".")+9, " \# Modified History:")
call append(line(".")+10, " \# 1.Create file. ".strftime("%Y.%m.%d")." Adam Ma")
call append(line(".")+11, "\###############################################################")
call append(line(".")+12, "\#!/bin/sh")
elseif &filetype == 'python'
call setline(1,"#!/usr/bin/env python3")
call append(line(".")+0,"# -*- coding: UTF-8 -*-")
call append(line(".")+1,"")
call append(line(".")+2,"def main():")
call append(line(".")+3," print(\'hello world\')")
call append(line(".")+4,"")
call append(line(".")+5,"if __name__ == \'__main__\':")
call append(line(".")+6," main()")
else
call setline(1, "/***************************************************************")
call append(line(".")+0, " * Copyright(c) 2005-".strftime("%Y")." TriHappy Technologies Co. Ltd.")
call append(line(".")+1, " * All right reserved.")
call append(line(".")+2, " *")
call append(line(".")+3, " * Filename : ".expand("%"))
call append(line(".")+4, " * Version : 1.0")
call append(line(".")+5, " * Abstract : ")
call append(line(".")+6, " * Author : Adam Ma")
call append(line(".")+7, " * Created Date : ".strftime("%Y.%m.%d"))
call append(line(".")+8, " *")
call append(line(".")+9, " * Modified History:")
call append(line(".")+10, " * 1.Create file. ".strftime("%Y.%m.%d")." Adam Ma")
call append(line(".")+11, " ***************************************************************/")
call append(line(".")+12, "")
endif
if expand("%:e") == 'cpp'
call append(line(".")+13, "#include <iostream>")
call append(line(".")+14, "using namespace std;")
call append(line(".")+15, "")
call append(line(".")+16, "int main(int argc, char const *argv[])")
call append(line(".")+17, "{")
call append(line(".")+18, " return 0;")
call append(line(".")+19, "}")
endif
if &filetype == 'c'
call append(line(".")+13, "#include <stdio.h>")
call append(line(".")+14, "#include <stdlib.h>")
call append(line(".")+15, "#include <string.h>")
call append(line(".")+16, "#include <stdbool.h>")
call append(line(".")+17, "")
call append(line(".")+18, "#define print(fmt, args...) printf(\"\\033[1m[ \%s ] \%03d\: \"fmt\"\\033\[0m\\n\\r\", __FUNCTION__, __LINE__, ##args)")
call append(line(".")+19, "")
call append(line(".")+20, "int main(int argc, char const *argv[])")
call append(line(".")+21, "{")
call append(line(".")+22, " return 0;")
call append(line(".")+23, "}")
endif
if expand("%:e") == 'h'
call append(line(".")+13, "#ifndef _".toupper(expand("%:t:r"))."_H_")
call append(line(".")+14, "#define _".toupper(expand("%:t:r"))."_H_")
call append(line(".")+15, "")
call append(line(".")+16, "")
call append(line(".")+17, "")
call append(line(".")+18, "#endif")
endif
if &filetype == 'java'
call append(line(".")+13,"public class ".expand("%:t:r")." {")
call append(line(".")+14," public static void main(String[] args) {")
call append(line(".")+15," }")
call append(line(".")+16,"}")
endif
endfunc
autocmd BufNewFile * normal G
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
"nerdtree
nnoremap <silent> <F3> :NERDTreeToggle<CR>
nnoremap <leader>j :%!python -m json.tool<CR>
" tagbar
let g:tagbar_width=35
let g:tagbar_autofocus=0
nmap <F6> :TagbarToggle<CR>
" LeaderF
let g:Lf_ShortcutB='<leader>b'
let g:Lf_DefaultMode='NameOnly'
let g:Lf_CursorBlink=0
let g:Lf_HideHelp=1
let g:Lf_ShowHidden=1
let g:Lf_ShowDevIcons=0
noremap <Leader>s :<C-U><C-R>=printf("Leaderf! rg -e \"%s\"", expand("<cword>"))<CR>
let g:Lf_PreviewInPopup = 1
let g:Lf_WindowPosition = 'popup'
"let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b3", 'font': "DejaVu Sans Mono for Powerline" }
let g:Lf_StlSeparator = { 'left': '', 'right': '' }
let g:Lf_PreviewResult = {'Function': 1, 'BufTag': 0 }
let g:Lf_ShowDevIcons = 1
let g:Lf_ShortcutF = "<leader>ff"
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
"ycm
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 0
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
let g:ycm_use_clangd = 1
let g:ycm_clangd_binary_path = "/usr/bin/clangd"
let g:ycm_clangd_uses_ycmd_caching = 1
let g:ycm_add_preview_to_completeopt = 0
"AutoPairsFlyMode
let g:AutoPairsFlyMode = 0
let NERDTreeIgnore=['.*\.pyc$','.*\.o$','.*\.ko$'] " 忽略.pyc .o .ko 结尾的文件
"fonts
let laststatus = 2
let g:airline_powerline_fonts = 1 "use fonts that powerline has patched
let g:Powerline_symbols='fancy'
标签:set,vimrc,配置,Vim,call,ycm,let,line,append
From: https://www.cnblogs.com/adam-ma/p/17974182