【編輯器】Vim學習筆記

0x00先放幾個比較好的學習資料

1.Vim入門基礎 http://www.jianshu.com/p/bcbe916f97e1
2.vim配置 http://blog.csdn.net/g_brightboy/article/details/14229139
3.簡明Vim練級攻略 http://coolshell.cn/articles/5426.html
4.http://blog.csdn.net/mu_zhou233/article/details/53045831javascript

0x01而後是配置文件

字體 Mac上用Monaco 20號(Monaco字體太漂亮了太可愛了),Windows上用16號php

"2017.7.20  g++ with macvim By gwj

let s:cpo_save = &cpo
set cpo&vim colorscheme macvim set cin set tabstop=4 set softtabstop=4 set shiftwidth=4 set nu set guitablabel=%M%t set ruler set autoindent set smartindent filetype on syntax on set showmatch set guifont=Monaco:h20 set mouse=a set selection=exclusive set selectmode=mouse,key nnoremap <F7> <Esc>:w<CR>:!g++ % -Wall -o nnoremap <F8> <Esc>:!./ nnoremap <F9> <Esc>:w<CR>:!g++ % -Wall -o a nnoremap <F10> <Esc>:!./a<CR> set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ +\ v:shell_error let $SSH_ASKPASS = simplify($VIM . '/../../MacOS') . '/macvim-askpass' let $SUDO_ASKPASS = $SSH_ASKPASS let &cpo = s:cpo_save unlet s:cpo_save
" Candy? MacOS

set number set ruler set tabstop=4 set shiftwidth=4 set autoindent set smartindent filetype on syntax on colorscheme solarized set showmatch set guifont=Monaco:h20 set mouse=a set selection=exclusive set selectmode=mouse,key nnoremap <F7> <Esc>:w<CR>:!g++ % -Wall -o nnoremap <F8> <Esc>:!./ nnoremap <F9> <Esc>:w<CR>:!g++ % -Wall -o a<CR> nnoremap <F10> <Esc>:!./a<CR>
"mhy12345
"Configure of Vundle
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " Default Plugin Plugin 'VundleVim/Vundle.vim' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' Plugin 'Valloric/YouCompleteMe' " 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
"
"Old encoding setting...
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 "Configure airline let molokai_original=1 let g:airline_theme="molokai" "始終顯示狀態欄 set laststatus=2 "打開tabline功能,方便查看Buffer和切換,省去了minibufexpl插件 let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#buffer_nr_show = 1 "設置切換Buffer快捷鍵" nnoremap <C-tab> :bn<CR> nnoremap <C-s-tab> :bp<CR> " 關閉狀態顯示空白符號計數 let g:airline#extensions#whitespace#enabled = 0 let g:airline#extensions#whitespace#symbol = '!' " 設置consolas字體"前面已經設置過 "set guifont=Consolas\ for\ Powerline\ FixedD:h11 if !exists('g:airline_symbols') let g:airline_symbols = {} endif "End "YouCompleteMe let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py' let g:airline_powerline_fonts = 1 "Own configure nnoremap <leader>f :YcmCompleter FixIt<CR> function Compile() if &filetype == 'cpp' exec "!g++ % -o %< -g -Wall -Wextra -Wconversion -std=c++11" elseif &filetype == 'c' exec "!gcc % -o %< -g -Wall -Wextra -Wconversion" elseif &filetype == 'pas' exec "!fpc % -g" elseif &filetype == 'tex' exec "!xelatex '%'" elseif &filetype == 'java' exec "!javac %" elseif &filetype == 'scss' exec "!sass % > %<.css" endif endfunction function Debug() if &filetype == 'cpp' exec "!gdb ./%<" elseif &filetype == 'tex' exec "!open './%<.pdf'" elseif &filetype == 'java' exec "!jdb %<" endif endfunction function Run() if &filetype == 'cpp' exec "!time ./%<" elseif &filetype == 'tex' exec "!open './%<.pdf'" elseif &filetype == 'java' exec "!java %<" elseif &filetype == 'ruby' exec "!ruby %" elseif &filetype == 'html' exec "!firefox %" elseif &filetype == 'php' exec "!php %" elseif &filetype == 'sh' exec "!bash %" endif endfunction set hlsearch set mouse=a set smartindent set fdm=marker set number set tabstop=4 set softtabstop=4 set shiftwidth=4 set backspace=2 syntax on imap jj <esc> map <F9> : call Compile() <CR> map <F5> : call Debug() <CR> map <F6> : call Run() <CR> map <F8> : ! xcodebuild <CR> map <F12> : ! subl ./% <CR> map <F2> : ! python3 % <CR> colors evening
"main command
"打開語法高亮
syntax on

"使用配色方案
colorscheme desert

"打開文件類型檢測功能
filetype on

"不一樣文件類型採用不一樣縮進
filetype indent on

"容許使用插件
filetype plugin on
filetype plugin indent on

"關閉vi模式
set nocp

"與windows共享剪貼板
set clipboard+=unnamed

"取消VI兼容,VI鍵盤模式不易用
set nocompatible

"顯示行號, 或set number
set nu

"歷史命令保存行數 
set history=100 

"當文件被外部改變時自動讀取
set autoread 

"取消自動備份及產生swp文件
set nobackup
set nowb
set noswapfile

"容許使用鼠標點擊定位
set mouse=a

"容許區域選擇
set selection=exclusive
set selectmode=mouse,key

"高亮光標所在行
set cursorline

"取消光標閃爍
set novisualbell

"老是顯示狀態行
set laststatus=2

"狀態欄顯示當前執行的命令
set showcmd

"標尺功能,顯示當前光標所在行列號
set ruler

"設置命令行高度爲3
set cmdheight=3

"粘貼時保持格式
set paste

"高亮顯示匹配的括號
set showmatch

"在搜索的時候忽略大小寫
set ignorecase

"高亮被搜索的句子
set hlsearch

"在搜索時,輸入的詞句的逐字符高亮(相似firefox的搜索)
set incsearch

"繼承前一行的縮進方式,特別適用於多行註釋
set autoindent

"爲C程序提供自動縮進
set smartindent

"使用C樣式的縮進
set cindent

"製表符爲4
set tabstop=4

"統一縮進爲4
set softtabstop=4
set shiftwidth=4

"容許使用退格鍵,或set backspace=2
set backspace=eol,start,indent
set whichwrap+=<,>,h,l

"取消換行
set nowrap

"啓動的時候不顯示那個援助索馬里兒童的提示
set shortmess=atI

"在被分割的窗口間顯示空白,便於閱讀
set fillchars=vert:\ ,stl:\ ,stlnc:\

"光標移動到buffer的頂部和底部時保持3行距離, 或set so=3
set scrolloff=3

"設定默認解碼
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936

"設定字體
set guifont=Courier_New:h11:cANSI
set guifontwide=新宋體:h11:cGB2312

"設定編碼
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

"自動補全
filetype plugin indent on
set completeopt=longest,menu

"自動補全命令時候使用菜單式匹配列表
set wildmenu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet

0x03具體操做

佔坑待填。css

相關文章
相關標籤/搜索