vim設定檔

  • 267
  • 0

我目前vim的設定檔,持續進化中


let mapleader = "z" " set leader key to z

" =================== Plugin Management Vundle======================
set rtp+=~/.vim/bundle/Vundle.vim
"set rtp+=/usr/local/lib/python3.8/dist-packages/powerline/bindings/vim/
" set rtp+=/home/vincent/.fzf/
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'  " Plugin Management
Plugin 'Valloric/YouCompleteMe' " code completion engine
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'

Plugin 'scrooloose/nerdcommenter' " comment tool  leader_key cc leader cu

call vundle#end()
" =================== Plugin Management Vundle======================

filetype plugin indent on

" YouCompleteMe
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf=0
let g:ycm_python_binary_path='/usr/bin/python3'
let g:ycm_autoclose_preview_window_after_completion=1


set nocompatible " 使用vim的新功能,而不用vi的
set hidden "切換顯示檔案後,被切走的是隱藏,不是關掉
set noswapfile "不要swap檔案

syntax on " 開啟語法高亮
set term=screen-256color-s
colorscheme burnttoast256 "顏色樣式

" 縮排設定/自動縮排
set autoindent 
set smartindent
set cindent 
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4

set showmatch " 顯示對應的刮號

set number " 顯示行號
set relativenumber " 顯示相對行號
set confirm " 開啟各種確認
set wrap " 自動斷行

set encoding=utf-8

" 隱藏滾動條
set guioptions-=r 
set guioptions-=L 
set guioptions-=b

" 字型設置
set guifont=Monaco:h13

set ignorecase " (ic)搜尋不分大小寫
set incsearch " 搜尋後自動跳到符合pattern的字
set hlsearch " 搜尋的字高亮
set cursorline " 行游標顯示
set cursorcolumn " 列游標顯示

" 設定當副檔名為以下時,有不同縮排
"au BufNewFile,BufRead *.js, *.html, *.css
"set tabstop=2
"set softtabstop=2
"set shiftwidth=2

" set statusline=%4*%<\%m%<[%f\%r%h%w]\[%{&ff},%{&fileencoding},%Y]%=\[Position=%l,%v,%p%%]
 

" F5自動執行python檔
map <F5> :Autopep8<CR> :w<CR> :call RunPython()<CR> 
function RunPython()
    let mp = &makeprg 
    let ef = &errorformat 
    let exeFile = expand("%:t") 
    setlocal makeprg=python\ -u 
    set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m 
    silent make % 
    copen 
    let &makeprg = mp 
    let &errorformat = ef 
endfunction

set splitbelow "向下分割視窗
set splitright "向右分割視窗

"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

nnoremap <Leader>so :source ~/.vimrc<CR> " 重新讀取vimrc

set laststatus=2
"let g:aireline_power_fonts=1
""set showtabline=2
""let g:Powerline_symbles= 'unicode'
""set noshowmode

let g:airline#extensions#tabline#enabled = 1
" set left separator
let g:airline#extensions#tabline#left_sep = ' '
" set left separator which are not editting
let g:airline#extensions#tabline#left_alt_sep = '|'
" show buffer number
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_theme='bubblegum'
let g:airline#extensions#branch#enabled = 1