Last active
January 25, 2023 06:19
-
-
Save SkylerHu/d4c5ba94f3b11253c3307e34a8895cf8 to your computer and use it in GitHub Desktop.
vim的配置
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
set ruler | |
set showcmd | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
set nu | |
set hlsearch | |
set incsearch | |
set colorcolumn=120 | |
set cul "高亮光标所在行 | |
autocmd InsertEnter * se cul " 用浅色高亮当前行 | |
set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | |
"set statusline=%<\ %n:%F\ %m%r%y%=%-35.(line:\ %l\ of\ %L,\ col:\ %c%V\ (%P)%) | |
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 | |
set laststatus=2 | |
set ignorecase | |
set backspace=indent,eol,start " backspace over everything in insert mode | |
set path=$PWD/** | |
"colorscheme molokai | |
"set cursorline | |
"hi clear CursorLine | |
"hi CursorLine gui=underline | |
"hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white | |
"hi colorcolumn ctermbg=Green guibg=seagreen | |
"so that when you preview the new file takes up 80% and the file explorer the other 20%. | |
let g:netrw_winsize=25 | |
let g:netrw_altv = 2 | |
let g:netrw_browse_split = 3 | |
let g:netrw_keepdir = 0 | |
let NERDTreeWinSize=30 | |
"let g:nerdtree_tabs_open_on_console_startup=1 | |
map <F2> :mksession! ~/.vim_session <cr> " Quick write session with F2 | |
map <F3> :source ~/.vim_session <cr> " And load session with F3 | |
execute pathogen#infect() | |
autocmd FileType python setlocal completeopt-=preview | |
function! ResCur() | |
if line("'\"") <= line("$") | |
normal! g`" | |
return 1 | |
endif | |
endfunction | |
augroup resCur | |
autocmd! | |
autocmd BufWinEnter * call ResCur() | |
augroup END | |
au BufNewFile,BufRead *.yml set filetype=xml | |
filetype plugin indent off | |
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" To ignore plugin indent changes, instead use: | |
"filetype plugin on | |
" | |
" 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 | |
Bundle 'cespare/vim-golang' | |
Bundle 'taglist.vim' | |
Bundle 'dhruvasagar/vim-table-mode' | |
Bundle 'godlygeek/tabular' | |
Bundle 'derekwyatt/vim-scala' | |
Bundle 'kien/ctrlp.vim' | |
Bundle 'Valloric/YouCompleteMe' | |
Bundle 'Yggdroot/indentLine' | |
let g:indentLine_char = '┊' | |
"powerline{ | |
set guifont=PowerlineSymbols\ for\ Powerline | |
set nocompatible | |
set t_Co=256 | |
let g:Powerline_stl_path_style = "full" | |
"} | |
"let Tlist_Auto_Open=1 | |
"let Tlist_Exit_OnlyWindow=1 | |
"let Tlist_Use_Right_Window = 1 | |
set paste | |
"ctags | |
set tags=./tags,tags; | |
set wildignore+=**/fe-dist/** | |
set wildignore+=**/node_modules/** | |
set wildignore+=**/log/** | |
set wildignore+=**/static/** | |
set wildignore+=*.swp,*.zip,*.pyc,.git/ | |
set path=.,,** | |
let g:table_mode_separator = '|' | |
let g:table_mode_fillchar = '-' | |
let g:table_mode_corner="|" | |
set foldnestmax=10 "deepest fold is 10 levels | |
set foldlevel=1 "this is just what i use | |
set foldmethod=marker | |
"syntax check | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_python_checkers=['flake8'] | |
let g:syntastic_python_flake8_args='--ignore W391,E501 --max-line-length 119' | |
let g:syntastic_loc_list_height=3 | |
let g:syntastic_enable_highlighting=0 | |
" ycm | |
let g:ycm_path_to_python_interpreter="/usr/bin/python" | |
"let g:ycm_path_to_python_interpreter="/usr/local/bin/python3" | |
let g:ctrlp_working_path_mode = 'ra' | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
let g:ctrlp_custom_ignore = { | |
\ 'dir': '[\/]\.(git|hg|svn)$', | |
\ 'file': '\.(exe|so|dll|pyc|swp)$', | |
\ 'link': 'log', | |
\ } | |
set encoding=utf-8 | |
" 自动缩进 | |
set autoindent | |
set cindent | |
set autoread " 设置当文件被改动时自动载入 | |
set wildmenu " 增强模式中的命令行自动完成操作 | |
set showcmd " 输入的命令显示出来,看的清楚些 | |
set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界 | |
set ruler " 显示标尺 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"""""新文件标题 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"新建.c,.h,.sh,.java文件,自动插入文件头 | |
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.rb,*.java,*.py exec ":call SetTitle()" | |
""定义函数SetTitle,自动插入文件头 | |
func SetTitle() | |
"如果文件类型为.sh文件 | |
if &filetype == 'sh' | |
call setline(1,"\#!/bin/bash") | |
call append(line("."), "") | |
elseif &filetype == 'python' | |
call setline(1,"#!/usr/bin/env python") | |
call append(line("."),"# coding=utf-8") | |
call append(line(".")+1, "") | |
endif | |
endfunc | |
autocmd BufNewFile * normal G | |
"列出当前目录文件 | |
map <F3> :NERDTreeToggle<CR> | |
imap <F3> <ESC> :NERDTreeToggle<CR> | |
"当打开vim且没有文件时自动打开NERDTree | |
autocmd vimenter * if !argc() | NERDTree | endif | |
" 只剩 NERDTree时自动关闭 | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
"""""""""""""""""""""""""""""" | |
" Tag list (ctags) | |
"""""""""""""""""""""""""""""""" | |
let Tlist_Ctags_Cmd = '/usr/local/bin/ctags' | |
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的 | |
let Tlist_File_Fold_Auto_Close = 1 | |
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim | |
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口 | |
nmap tl :Tlist<cr> | |
filetype plugin indent on | |
"打开文件类型检测, 加了这句才可以用智能补全 | |
set completeopt=preview,menu | |
set completeopt=longest,menu | |
"python补全 | |
let g:pydiction_location = '~/.vim/after/complete-dict' | |
let g:pydiction_menu_height = 20 | |
let Tlist_Ctags_Cmd='/usr/local/bin/ctags' | |
let g:miniBufExplMapWindowNavVim = 1 | |
let g:miniBufExplMapWindowNavArrows = 1 | |
let g:miniBufExplMapCTabSwitchBufs = 1 | |
let g:miniBufExplModSelTarget = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/sh
if [ ! -d ~/.vim ]; then
mkdir ~/.vim
fi
cd ~/.vim
if [ ! -d bundle ]; then
mkdir bundle
fi
cd bundle
git clone git://github.com/Lokaltog/vim-powerline.git
git clone https://github.com/gmarik/Vundle.vim.git
git clone https://github.com/scrooloose/nerdtree.git
git clone https://github.com/jistr/vim-nerdtree-tabs.git
git clone [email protected]:vim-scripts/taglist.vim.git
git clone [email protected]:vim-scripts/AutoTag.git
git clone https://github.com/scrooloose/syntastic.git
git clone https://github.com/tpope/vim-fugitive.git
git clone [email protected]:Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
/bin/sh install.sh
cd ..
mkdir -p ~/.vim/autoload ~/.vim/bundle && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim