0.查看vi配置,在終端輸入vi,即可查看vi版本信息
1.安裝gcc/g++
cent中使用yum來配置gcc/g++,若要安裝,在終端輸入sudo yum install gcc-c++(非root用戶)
2.配置gdb
在終端輸入sudo yum install gdb(非root用戶)按回車執行
3.配置vim
vim配置
vim 是Linux的一種文本編輯器。?
vim模式:三種模式:普通模式、插入模式、底行模式 ?
簡單配置vim:在用戶根目錄下找到一個隱藏文件名為.vimrc將其內容改變為以下代碼即可完成配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 一般設定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 設定默認解碼
set fenc=utf-
8
set fencs=utf-
8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
" 不要使用vi的鍵盤模式,而是vim自己的
set nocompatible
" history文件中需要記錄的行數
set history=
100 " 在處理未保存或只讀文件的時候,彈出確認
set confirm
" 與windows共享剪貼板
set clipboard+=unnamed
" 偵測文件類型
filetype on
" 載入文件類型插件
filetype plugin on
" 為特定文件類型載入相關縮進文件
filetype indent on
" 保存全局變量
set viminfo+=!
" 帶有如下符號的單詞不要被換行分割
set iskeyword+=_,$,@,%,
#,- " 語法高亮
syntax on
" 高亮字符,讓其不受100列限制
:highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white
:match OverLength '\%
101v.*'
" 狀態行顏色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文件設置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 不要備份文件(根據自己需要取舍)
set nobackup
" 不要生成swap文件,當buffer被丟棄的時候隱藏它
setlocal noswapfile
set bufhidden=hide
" 字符間插入的像素行數目
set linespace=
0 " 增強模式中的命令行自動完成操作
set wildmenu
" 在狀態行上顯示光標所在位置的行號和列號
set ruler
set rulerformat=%
20(%
2*%<%f%=\ %m%r\ %
3l\ %c\ %p%%%)
" 命令行(在狀態行下)的高度,默認為1,這里是2
set cmdheight=
2 " 使回格鍵(backspace)正常處理indent, eol, start等
set backspace=
2 " 允許backspace和光標鍵跨越行邊界
set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠標(類似office中在工作區雙擊鼠標定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 啟動的時候不顯示那個援助索馬里兒童的提示
set shortmess=atI
" 通過使用: commands命令,告訴我們文件的哪一行被改變過
set report=
0 " 不讓vim發出討厭的滴滴聲
set noerrorbells
" 在被分割的窗口間顯示空白,便于閱讀
set fillchars=vert:\ ,stl:\ ,stlnc:\
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 搜索和匹配
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 高亮顯示匹配的括號
set showmatch
" 匹配括號高亮的時間(單位是十分之一秒)
set matchtime=
5 " 在搜索的時候忽略大小寫
set ignorecase
" 不要高亮被搜索的句子(phrases)
set nohlsearch
" 在搜索時,輸入的詞句的逐字符高亮(類似firefox的搜索)
set incsearch
" 輸入:set list命令是應該顯示些啥?
set listchars=tab:\
|\ ,trail:.,extends:>,precedes:<,eol:$ " 光標移動到buffer的頂部和底部時保持3行距離
set scrolloff=
3 " 不要閃爍
set novisualbell
" 我的狀態行顯示的內容(包括文件類型和解碼)
set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\
"%d/%m/%y\ -\ %H:%M\")}
" 總是顯示狀態行
set laststatus=
2 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文本格式和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 自動格式化
set formatoptions=tcrqn
" 繼承前一行的縮進方式,特別適用于多行注釋
set autoindent
" 為C程序提供自動縮進
set smartindent
" 使用C樣式的縮進
set cindent
" 制表符為4
set tabstop=
4 " 統一縮進為4
set softtabstop=
4
set shiftwidth=
4 " 不要用空格代替制表符
set noexpandtab
" 不要換行
set nowrap
" 在行和段開始處使用制表符
set smarttab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags的設定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按照名稱排序
let Tlist_Sort_Type =
"name" " 在右側顯示窗口
let Tlist_Use_Right_Window =
1 " 壓縮方式
let Tlist_Compart_Format =
1 " 如果只有一個buffer,kill窗口也kill掉buffer
let Tlist_Exist_OnlyWindow =
1 " 不要關閉其他文件的tags
let Tlist_File_Fold_Auto_Close =
0 " 不要顯示折疊樹
let Tlist_Enable_Fold_Column =
0 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 只在下列文件類型被偵測到的時候顯示行號,普通文本文件不顯示 if has(
"autocmd")
autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o-->
autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o
autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=
100
autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
autocmd BufReadPost *
\ if line(
"'\"") > 0 && line("'\
"") <= line(
"$")
|
\ exe
" normal g`\"" |
\ endif
endif
"has("autocmd
") " F5編譯和運行C程序,F6編譯和運行C++程序
" 請注意,下述代碼在windows下使用會報錯
" 需要去掉./這兩個字符 " C的編譯和運行
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec
"w"
exec
"!gcc % -o %<"
exec
"! ./%<"
endfunc
" C++的編譯和運行
map <F6> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec
"w"
exec
"!g++ % -o %<"
exec
"! ./%<"
endfunc
" 能夠漂亮地顯示.NFO文件
set encoding=utf-
8
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction au BufReadPre *.nfo call SetFileEncodings('cp437')
|set ambiwidth=single au BufReadPost *.nfo call RestoreFileEncodings() " 高亮顯示普通txt文件(需要txt.vim腳本)
au BufRead,BufNewFile * setfiletype txt
" 用空格鍵來開關折疊
set foldenable
set foldmethod=manual
nnoremap <space> @=((foldclosed(line('.')) <
0) ? 'zc':'zo')<CR>
" minibufexpl插件的一般設置
let g:miniBufExplMapWindowNavVim =
1
let g:miniBufExplMapWindowNavArrows =
1
let g:miniBufExplMapCTabSwitchBufs =
1
let g:miniBufExplModSelTarget =
1
總結
以上是生活随笔為你收集整理的如何使用命令安装gcc/g++, gdb, vim的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。