" " Setting some decent VIM settings for programming " This source file comes from git-for-windows build-extra repository (git-extra/vimrc)
ru! defaults.vim " Use Enhanced Vim defaults set mouse= " Reset the mouse setting from defaults aug vimStartup | au! | aug END " Revert last positioned jump, as it is defined below let g:skip_defaults_vim = 1 " Do not source defaults.vim again (after loading this system vimrc)
set nocompatible set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() "call vundle#begin('~/some/path/here')
Plugin 'VundleVim/Vundle.vim'
Plugin 'vimwiki/vimwiki'
call vundle#end() filetype plugin indent on
set ai " set auto-indenting on for programming set showmatch " automatically show matching brackets. works like it does in bbedit. set vb " turn on the "visual bell" - which is much quieter than the "audio blink" set laststatus=2 " make the last line where the status is two lines deep so you can see status always set showmode " show the current mode set clipboard=unnamed " set clipboard to unnamed to access the system clipboard under windows set wildmode=list:longest,longest:full " Better command line completion
" Show EOL type and last modified timestamp, right after the filename " Set the statusline set statusline=%f " filename relative to current $PWD set statusline+=%h " help file flag set statusline+=%m " modified flag set statusline+=%r " readonly flag set statusline+=\ [%{&ff}] " Fileformat [unix]/[dos] etc... set statusline+=\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))}) " last modified timestamp set statusline+=%= " Rest: right align set statusline+=%l,%c%V " Position in buffer: linenumber, column, virtual column set statusline+=\ %P " Position in buffer: Percentage
" User define set autoindent set cindent set shiftwidth=4 set softtabstop=4 set ts=2 set expandtab set number set mps+=<:> set guifont=Consolas:h10 #gvim设置字体,linux下可能不同 nmap <CR> o<ESC> #键盘映射,Enter键映射为 o + ESC syntax on filetype plugin on imap {<CR> {<CR>}<ESC>O imap [ []<ESC>i imap ( ()<ESC>i "设置跳出自动补全的括号 func SkipPair() if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'" || getline('.')[col('.') - 1] == '}' || getline('.')[col('.') - 1] == '>' return "\<ESC>la" else return "\t" endif endfunc " 将tab键绑定为跳出括号 inoremap <TAB> <c-r>=SkipPair()<CR>
if &term =~ 'xterm-256color' " mintty identifies itself as xterm-compatible if &t_Co == 8 set t_Co = 256 " Use at least 256 colors endif " set termguicolors " Uncomment to allow truecolors on mintty endif "------------------------------------------------------------------------------ " Only do this part when compiled with support for autocommands. if has("autocmd") " Set UTF-8 as the default encoding for commit messages autocmd BufReadPre COMMIT_EDITMSG,MERGE_MSG,git-rebase-todo setlocal fileencodings=utf-8
" Remember the positions in files with some git-specific exceptions" autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") \ && &filetype !~# 'commit\|gitrebase' \ && expand("%") !~ "ADD_EDIT.patch" \ && expand("%") !~ "addp-hunk-edit.diff" | \ exe "normal g`\"" | \ endif
autocmd BufNewFile,BufRead *.patch set filetype=diff
" Set cursor shape and color if &term =~ "xterm" " INSERT mode let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7" " REPLACE mode let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7" " NORMAL mode let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7" endif " 1 -> blinking block 闪烁的方块 " 2 -> solid block 不闪烁的方块 " 3 -> blinking underscore 闪烁的下划线 " 4 -> solid underscore 不闪烁的下划线 " 5 -> blinking vertical bar 闪烁的竖线 " 6 -> solid vertical bar 不闪烁的竖线
" vimwiki let g:vimwiki_use_mouse = 1 let g:vimwiki_list = [{'path': '/d/vimwiki/', \ 'path_html': '/d/vimwiki/html/', \ 'html_header': '/d/vimwiki/template/header.tpl',}]
7.git配置分支
此项应该在bashrc中配置,之前搞错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#来源:公众号【编程珠玑】 git_branch() { branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null` if [ "${branch}" != "" ] then if [ "${branch}" = "(no branch)" ] then branch="(`git rev-parse --short HEAD`...)" fi echo "($branch)" fi }