小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

linux vi vim 配置 用于寫(xiě)c語(yǔ)言

 書(shū)*金 2015-01-30

先說(shuō)一下vi和vim的區(qū)別:

它們都是多模式編輯器,不同的是vim 是vi的升級(jí)版本,它不僅兼容vi的所有指令,而且還有一些新的特性在里面。
vim的這些優(yōu)勢(shì)主要體現(xiàn)在以下幾個(gè)方面:
1、多級(jí)撤消
我們知道在vi里,按 u只能撤消上次命令,而在vim里可以無(wú)限制的撤消。
2、易用性
vi只能運(yùn)行于unix中,而vim不僅可以運(yùn)行于unix,windows ,mac等多操作平臺(tái)。
3、語(yǔ)法加亮
vim可以用不同的顏色來(lái)加亮你的代碼。
4、可視化操作
就是說(shuō)vim不僅可以在終端運(yùn)行,也可以運(yùn)行于x window、 mac os、 windows。
5、對(duì)vi的完全兼容
某些情況下,你可以把vim當(dāng)成vi來(lái)使用。

我前段時(shí)間也下載使用了vim編輯器,我用的xp系統(tǒng),之前在linux SUSE下也用過(guò)vi,個(gè)人感覺(jué)是vim相對(duì)于vi來(lái)說(shuō),擴(kuò)展性更強(qiáng)了,以前使用vi時(shí)ctrl+s和ctrl+z之類(lèi)的是不能用的(應(yīng)該沒(méi)有記錯(cuò)),但是vim就可以的。
然后,介紹一下用vi 寫(xiě)c程序的話,主要的一些配置:

一種方法是在vi 的底行模式下,輸入一些配置命令,如  :set all 顯示所有配置選項(xiàng)。

:set hlsearch
:set backspace=2
:set smartindent
:sysntax on

然后按 Esc,輸入:wq退出
下面逐一解釋一下:

:set hlsearch           作用:將搜索字符串反白
:set backspace=2    作用:可以刪除任意值(經(jīng)常輸入錯(cuò)誤,所以要?jiǎng)h掉)
:set smartindent      作用:自動(dòng)縮進(jìn)(這個(gè)是最重要的,要不麻煩,程序些出來(lái)不整齊)
:sysntax on             作用:根據(jù)語(yǔ)法顯示不同的顏色(檢查語(yǔ)法,要是有顏色不對(duì)的,肯定有些錯(cuò)的地方)

還有就是你想一次搞定,以后不用再臨時(shí)配置的話,你就修改vim的配置文件。

配置vim的方法是在用戶(hù)主目錄下建立個(gè).vimrc文件,我一般使用root帳戶(hù),所以就在/root/下建立一個(gè).vimrc文件:vi /root/.vimrc。

一下是一些關(guān)于vim常用的配置說(shuō)明:

"語(yǔ)法高亮
syntax on
"顯示行號(hào)
set nu

"修改默認(rèn)注釋顏色
hi Comment ctermfg=DarkCyan

"允許退格鍵刪除
set backspace=2
"啟用鼠標(biāo)
set mouse=a
set selection=exclusive
set selectmode=mouse,key

"偵測(cè)文件類(lèi)型
filetype on
"載入文件類(lèi)型插件
filetype plugin on
"為特定文件類(lèi)型載入相關(guān)縮進(jìn)文件
filetype indent on

"設(shè)置編碼自動(dòng)識(shí)別, 中文引號(hào)顯示
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936
set encoding=euc-cn
set ambiwidth=double

"設(shè)置高亮搜索
set hlsearch
"在搜索時(shí),輸入的詞句的逐字符高亮
set incsearch

"按C語(yǔ)言格式縮進(jìn)
set cindent
"設(shè)置Tab長(zhǎng)度為4格
set tabstop=4
"設(shè)置自動(dòng)縮進(jìn)長(zhǎng)度為4格
set shiftwidth=4
"繼承前一行的縮進(jìn)方式,特別適用于多行注釋
set autoindent
"顯示括號(hào)匹配
set showmatch
"括號(hào)匹配顯示時(shí)間為1(單位是十分之一秒)
set matchtime=1

"增強(qiáng)模式中的命令行自動(dòng)完成操作
set wildmenu
"不要生成swap文件,當(dāng)buffer被丟棄的時(shí)候隱藏它
setlocal noswapfile
set bufhidden=hide
=====================================================================
syntax on
set nu

set fileencodings=utf-8,gbk

set tabstop=4
set shiftwidth=4
set expandtab

好了,就說(shuō)到這吧。

下面把.vimrc 的一個(gè)模板放在這:

" An example for a vimrc file.
"
" Maintainer:   Bram Moolenaar <>
" Last change:  2002 May 28
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"             for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"           for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set autoindent          " always set autoindenting on
if has("vms")
  set nobackup          " do not keep a backup file, use versions instead
else
  set backup            " keep a backup file
endif
set history=50          " keep 50 lines of command line history
set ruler               " show the cursor position all the time
set showcmd             " display incomplete commands
set incsearch           " do incremental searching
set nu
set smartindent
set mouse=a
set selection=exclusive
set selectmode=mouse,key
set nobackup
set nowritebackup
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936
set encoding=euc-cn
"set ambiwidth=double
set shiftwidth=4
set cindent

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

endif " has("autocmd")

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約