前言:
情景一:
或許你曾經(jīng)歷過以下情景
電腦換了幾次,電腦上的代碼項(xiàng)目和開發(fā)工具老是要重新安裝和搬遷。
離開個(gè)人電腦就不能做自己的事了(如在公司沒事干的時(shí)候可以鼓搞下自己現(xiàn)在手上正在弄的項(xiàng)目或者看的項(xiàng)目等)
想需要一個(gè)只要有網(wǎng)絡(luò)就能開發(fā)的環(huán)境,這樣可以考慮用vim等linux編輯器了,這樣可以用ssh遠(yuǎn)程服務(wù)器開發(fā)了。
編輯器概覽:
SublimeText
Window 下使用不錯(cuò) 最近挺火我也用過一段時(shí)間感覺不錯(cuò), 不過限制了圖形UI界面了,不能遠(yuǎn)程開發(fā)。
NotePad++
Window 使用可以 比較輕量用過一段時(shí)間感覺沒Sublime Text 好. 我一般電腦都裝來(lái)編輯其他文本和記錄事項(xiàng)。
Vim
Linux 上的必裝的文件編輯器,有豐富的插件,可以滿足各種語(yǔ)言開發(fā)。輕量沒有IDE那么重量級(jí)。主要能ssh遠(yuǎn)程上開發(fā)使用。
雖然Emac也好用,但個(gè)人沒入坑,就不用了vim感覺滿足個(gè)人的需求了。
Emac
Linux 上挺受歡迎開發(fā)編輯器之一。(個(gè)人沒入坑)
各種開發(fā)語(yǔ)言IDE
比喻C# vistual studio, php phpstorm, python pycharm, java eclipse等等! 感覺比較局限某些語(yǔ)言。
其他(不一一列舉)
建立vim編輯器的開發(fā)工具只要三步
步驟:
1.建立vim管理工具(vundle)
vundle 項(xiàng)目托管在github上 https://github.com/gmarik/vundle。
其特色在于使用git來(lái)管理插件,更新方便,支持搜索,一鍵更新,從此只需要一個(gè)vimrc走天下
獲?。?br>
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
編輯你當(dāng)前用戶下的.vimrc
ubuntu@VM-37-16-ubuntu:~$ vim ~/.vimrc
輸入Vundle對(duì)應(yīng)的配置
"======================== Vundle 配置 ============================
"安裝方法用這個(gè):git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/ "載入特定目錄插件
call vundle#rc()
2.從github上獲取想要的插件
選擇你的插件
vim 插件介紹推薦十大必備插件
然后在.vimrc中填上你的插件
如下我個(gè)人的部分配置:
"======================== Vundle 配置 ============================
"安裝方法用這個(gè):git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/ "載入特定目錄插件
call vundle#rc()
"======================= 輸入要安裝的插件 =========================
Bundle 'gmarik/vundle'
Bundle 'Lucius'
"tag顯示列表
"Bundle 'vim-scripts/taglist.vim'
"增強(qiáng)的狀態(tài)欄
Bundle 'bling/vim-airline'
"模擬sublime的ctrl-p快捷鍵,支持模糊搜索打開文件
Bundle 'kien/ctrlp.vim'
"配色工具
Bundle 'altercation/vim-colors-solarized'
"對(duì)ctrlp.vim模糊搜索算法改進(jìn)的插件
Bundle 'JazzCore/ctrlp-cmatcher'
"<([等括號(hào)自動(dòng)補(bǔ)全插件(模擬sublime)
Bundle 'vim-scripts/delimitMate.vim'
"快速跳轉(zhuǎn)光標(biāo)的插件
Bundle 'easymotion/vim-easymotion'
"進(jìn)行縮進(jìn)對(duì)齊的插件
Bundle 'vim-easy-align'
"minibuff
Bundle 'vim-scripts/minibufexplorerpp'
"tagbar
Bundle 'majutsushi/tagbar'
"BerdTree目錄
Bundle 'scrooloose/nerdtree'
"python語(yǔ)法檢查
Bundle 'PyCQA/pyflakes'
"python tag compelte
Bundle 'vim-scripts/Pydiction'
"markdown 語(yǔ)法
Bundle 'plasticboy/vim-markdown'
"自動(dòng)完成輸入
Bundle 'SirVer/ultisnips'
Bundle 'honza/vim-snippets'
"配色
Bundle 'flazz/vim-colorschemes'
在.vimrc 配置好你的需要插件后,打開vim
命令模式:輸入BundleInstall 來(lái)安裝

3.在.vimrc中創(chuàng)建對(duì)應(yīng)的調(diào)用
插件配置和快捷鍵設(shè)置
每個(gè)插件配置的內(nèi)容不盡相同,有的插件默認(rèn)的可以用,詳細(xì)看對(duì)應(yīng)的插件的文檔。
如:
"====================== airline setting ==========================
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:Powerline_symbols='fancy'
"airline設(shè)置
set laststatus=2
"使用powerline打過補(bǔ)丁的字體
let g:airline_powerline_fonts = 0
let Powerline_symbols='fancy'
let g:bufferline_echo=0
"開啟tabline
let g:airline#extensions#tabline#enabled = 1
"tabline中當(dāng)前buffer兩端的分隔字符
let g:airline#extensions#tabline#left_sep = ' '
"tabline中未激活buffer兩端的分隔字符
let g:airline#extensions#tabline#left_alt_sep = '|'
"tabline中buffer顯示編號(hào)
let g:airline#extensions#tabline#buffer_nr_show = 1
"映射切換buffer的鍵位
nnoremap [b :bp<CR>
nnoremap ]b :bn<CR>
"======================== ctrlP 設(shè)置 ============================
let g:NERDTreeChDirMode = 2
let g:ctrlp_working_path_mode = 'rw'
let g:ctrlp_max_depth = 40
let g:ctrlp_max_files = 50000
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
個(gè)人vim中用到的一些配置:
"python 自動(dòng)補(bǔ)全
autocmd FileType python set omnifunc=pythoncomplete#Complete
"php 自動(dòng)補(bǔ)全
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set fencs=utf-8,GB18030,ucs-bom,default,latin1
set number "顯示行號(hào)
syntax on "語(yǔ)法高亮
syntax enable "語(yǔ)法高亮
set showmatch " 括號(hào)匹配
set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns
set tabstop=4 " a hard TAB displays as 4 columns
set expandtab " insert spaces when hitting TABs
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE
set shiftround " round indent to multiple of 'shiftwidth'
"set autoindent " align the new line indent with the previous line
set hlsearch " set height line search "
set mouse=a "set mouse on
filetype plugin on
let g:pydiction_location = '~/.vim/bundle/Pydiction/complete-dict'
let g:pydiction_menu_height = 20
附上使用vim使用技巧
vim參考手冊(cè)
vim高級(jí)技巧開發(fā)篇
vimscript學(xué)習(xí)鏈接
這個(gè)可以幫助編寫一些函數(shù)或者開發(fā)個(gè)人插件。
如:
"快捷鍵設(shè)置,按F11調(diào)用
nmap <F11> :call RunOneFile()<CR>
"根據(jù)文件類型調(diào)用編譯器去調(diào)用這個(gè)文件
function RunOneFile()
if &filetype=="php"
echo $filetype
call RunPhpFile()
endif
if &filetype=="python"
call RunPythonFile()
endif
endfunction
"python 文件
function RunPythonFile()
let curpath=getcwd()
let fullpath=expand("%:p")
echo fullpath
execute "!python ".fullpath
endfunction
"php 文件
function RunPhpFile()
let curpath=getcwd()
let fullpath=expand("%:p")
echo fullpath
execute "!php ".fullpath
endfunction
附上個(gè)人配置的效果圖:
