新聞中心
1. 安裝gcc, g++環(huán)境
新的Ubuntu系統(tǒng)一般都已經(jīng)安裝好,可通過 “gcc –version” 以及 “g++ –version” 查看是否已經(jīng)安裝好;如果沒有安裝,命令如下:

sudo apt-get install build-essential
sudo apt-get install g++-4.4
2. 安裝Vim
sudo apt-get install vim vim-scripts vim-doc
并創(chuàng)建如下.vimrc文件和三個目錄,安裝插件大概就是將.plugin和.doc文件放到對應(yīng)的目錄中(解壓縮時選擇合并即可)然后修改.vimrc文件即可;
~/.vimrc(~/.vimrc文件中的配置會覆蓋/etc/vimrc中的配置);
~/.vim/plugin
~/.vim/doc
~/.vim/syntax
.vimrc中常用定義:
"設(shè)置編碼
set encoding=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set fileencodings=utf-8,ucs-bom,chinese
"語言設(shè)置
set langmenu=zh_CN.UTF-8
"設(shè)置行號
set nu
"設(shè)置語法高亮
syntax enable
syntax on
"設(shè)置配色方案
colorscheme desert
"可以在buffer的任何地方使用鼠標(biāo)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"高亮顯示匹配的括號
set showmatch
"去掉vi一致性
set nocompatible
"設(shè)置縮進
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cindent
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
"打開文件類型自動檢測功能
filetype on
3. 安裝vim中文文檔
vim中文幫助文檔tar包下載地址:http://sourceforge.net/projects/vimcdoc/files/vimcdoc/
解壓后其中有個doc文件夾, 將其中的內(nèi)容全部復(fù)制到~/.vim/doc, 或者vim安裝目錄下的doc目錄中, 此時vim中的help信息已經(jīng)是中文的了.
4. 安裝Ctags
安裝命令:
sudo apt-get install ctags
并在.vimrc文件中添加:
" Ctags
map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
在Vim中按下Ctrl-F12快捷鍵自動生成tags文件。命令執(zhí)行完后,會在源代碼目錄生成tags文件。Vim默認(rèn)會自動讀取當(dāng)前目錄下的tags文件,所以不需要修改~/.vimrc文件。此時,我們已經(jīng)具有定義跳轉(zhuǎn)的功能了。有兩組快捷鍵是最常用的。
Ctrl-] 跳轉(zhuǎn)到光標(biāo)所在符號的定義;
Ctrl-t 回到上次跳轉(zhuǎn)前的位置;
在Vim命令行下運行help ctags查詢更多功能。
5.其它插件安裝
- Taglist: 提供源代碼符號的結(jié)構(gòu)化視圖。
- Cscope: 提供交互式查詢語言符號功能,如查詢哪些地方使用某個變量或調(diào)用某個函數(shù)。
- OmniCppComplete: 主要提供輸入時實時提供類或結(jié)構(gòu)體的屬性或方法的提示和補全。
- SuperTab: 使Tab快捷鍵具有更快捷的上下文提示功能。
- NERDTree: 提供樹形瀏覽文件系統(tǒng)的界面。
- MiniBufExplorer: 提供多文件同時編輯功能。
- Winmanager: 將這NERDTree界面和Taglist界面整合起來,使Vim更像VS!
這些插件更新較慢,匯總后的插件(更新截止2017-02-14)
可以到主機寶貝資源站下載:
具體下載目錄在 /2017年資料/9月/29日/Ubuntu配置C++開發(fā)環(huán)境以及Vim的配置/
你也可以自己下載最新插件版本,下載地方分別為:
- Taglist: http://www.vim.org/scripts/script.php?script_id=273
- Cscope: http://cscope.sourceforge.net/cscope_maps.vim
- OmniCppComplete: http://www.vim.org/scripts/script.php?script_id=1520
- SuperTab: http://www.vim.org/scripts/script.php?script_id=1643
- NERDTree: http://www.vim.org/scripts/script.php?script_id=1658
- MiniBufExplorer: http://www.vim.org/scripts/script.php?script_id=159
- Winmanager: http://www.vim.org/scripts/script.php?script_id=95
全部.vimrc內(nèi)容如下:
"設(shè)置編碼 set encoding=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set fileencodings=utf-8,ucs-bom,chinese "語言設(shè)置
set langmenu=zh_CN.UTF-8
"設(shè)置行號 set nu "設(shè)置語法高亮
syntax enable
syntax on
"設(shè)置配色方案 colorscheme desert "可以在buffer的任何地方使用鼠標(biāo)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"高亮顯示匹配的括號 set showmatch "去掉vi一致性
set nocompatible
"設(shè)置縮進 set tabstop=4 set softtabstop=4 set shiftwidth=4 set autoindent set cindent if &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dm endif "打開文件類型自動檢測功能
filetype on
"Ctags map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . "TagList
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
"OmniCppComplete set nocp filetype plugin on "SuperTab
let g:SuperTabDefaultCompletionType="context"
"MiniBufExplorer let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 let g:miniBufExplMoreThanOne=0 let g:miniBufExplorerMoreThanOne=0 "NERDTree WinManager
let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree|TagList"
let g:bufExplorerMaxHeight=30
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap wm :WMToggle
當(dāng)前文章:Ubuntu配置C++開發(fā)環(huán)境以及Vim的配置
當(dāng)前URL:http://www.dlmjj.cn/article/djjoepj.html


咨詢
建站咨詢
