(原創) Gvim 個人習慣常用設定 (vim)

时间:2023-03-09 16:03:17
(原創) Gvim 個人習慣常用設定 (vim)

不定期更新這篇,因為查詢到好用的設定或者插件就會更新自己的設定。

let $LANG="zh_TW.UTF-8"
set langmenu=zh_tw.utf-8
set encoding=utf8

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

set nobackup
set noundofile
set noswapfile
":imap ( ()<ESC>i
":imap { {<CR>}<ESC>O
":imap [ []<ESC>i

"-----------------------------------------------------------
" Vundle
"-----------------------------------------------------------
set nocompatible
filetype off
set rtp+=$VIM/vimfiles/bundle/Vundle.vim
call vundle#begin('$VIM/vimfiles/bundle/')
Plugin 'gmarik/Vundle.vim'
Plugin 'L9'
Plugin 'scrooloose/nerdtree'
Bundle 'majutsushi/tagbar'
call vundle#end()
filetype plugin indent on

"-----------------------------------------------------------
" NERDTree & tagbar
"-----------------------------------------------------------
nmap <F2> :NERDTreeToggle <CR>
nmap <F3> :Tagbar <CR>
autocmd VimEnter * NERDTree
autocmd VimEnter * Tagbar
let g:tagbar_ctags_gin = '$VIM/ctags/ctags.exe'
set tags=tags

"-----------------------------------------------------------
" short key setting
"-----------------------------------------------------------
nmap ,s :e $VIM/_vimrc
imap aa <C-N>
nmap qw <C-Q>
nmap <Space>j <C-W>j
nmap <Space>h <C-W>h
nmap <Space>k <C-W>k
nmap <Space>l <C-W>l
nmap <F1> :Explore<CR>
imap aa <C-N>

"-----------------------------------------------------------
" GUI setting
"-----------------------------------------------------------
set t_Co=256
set nu
set incsearch
set ai
set cursorline
set tabstop=4
set shiftwidth=4
set ignorecase
syntax on
set laststatus=2
set columns=180
set lines=50

"-----------------------------------------------------------
" GVim mapping key
"-----------------------------------------------------------
"<BS> Backspace
"<Tab> Tab
"<CR> Enter
"<Enter> Enter
"<Return> Enter
"<Esc> Escape
"<Space> Space
"<Up> Up arrow
"<Down> Down arrow
"<Left> Left arrow
"<Right> Right arrow
"<F1> - <F12> Function keys 1 to 12
"#1, #2..#9,#0 Function keys F1 to F9, F10
"<Insert> Insert
"<Del> Delete
"<Home> Home
"<End> End
"<PageUp> Page-Up
"<PageDown> Page-Down
"<bar> the '|' character, which otherwise needs to be escaped '\|'