centos 如何配置vim 编辑器

1.注释:必须是vim命令 而不是vi命令

1.安装依赖的工具

$ sudo yum install git

$ sudo yum install wget

$ sudo yum install gcc

$ sudo yum install gcc-++

$ sudo yum install gcc-gfortran

$ sudo yum install make

$ sudo yum install gdb

$ sudo yum install cmake

$ sudo yum install clang

$ sudo yum install clang-analyzer

$ sudo yum install vim

2.安装python python 所需要的的依赖库

$sudo yum install python

$sudo yum install python-devel

3.手动安装cmak 编辑器

3.1cmake 官网下载 (https://cmake.org/download/)官网地址下载3.5 以上的版本

3.2 解压 、编译、安装

./configure --prefix=/YouPathToInstall/Cmake

make

make install

4.安装clang

首先,从http://llvm.org/releases/download.html#3.3这边下载最新的版本。如果从SVN下载代码的话,已经是3.4的开发版本了,如果需要使用稳定版本,推荐自己下载3.3的代码包,需要下载5个文件:

LLVM source code

Clang source code

Clang Tools Extra source code

Compiler RT source code

LibC++ source code

下载好了以后,四个压缩包都解压出来,得到四个目录:

llvm-3.3.src

cfe-3.3.src

clang-tools-extra-3.3.src

compiler-rt-3.3.src

libcxx-3.3.src

然后按下面的步骤组织:

mv cfe-3.3.src clang

mv clang/ llvm-3.3.src/tools/

mv clang-tools-extra-3.3.src extra

mv extra/ llvm-3.3.src/tools/clang/

mv compiler-rt-3.3.src compiler-rt

mv compiler-rt llvm-3.3.src/projects/

这样以后clangclang-tools-extracompiler-rt就可以和llvm一起编译了。

llvm-3.3.src同一层目录上新建个目录build-3.3并进入:

mkdir build-3.3

cd build-3.3

然后configure

../llvm-3.3.src/configure --enable-optimized --enable-targets=host-only

注意:这边两个选项推荐大家加上,否则会产生巨大的文件,我第一次编译的时候,没有加上这两个选项,编译出来的结果多大9.4G(够吓人的吧?把我的磁盘都耗尽了,还报错,google了好久才发现是磁盘空间不够),耗时超过一个半小时,加上以后编译出来的结果不到1Gi5四核20分钟多一点就编译完成。

然后make

make -j4

然后make install

sudo make install

clang++ -v查看下:

clang version 3.3 (tags/RELEASE_33/final)

Target: x86_64-unknown-linux-gnu

Thread model: posix





 

5.下载安装vim

git clone https://github.com/vim/vim.git

cd vim

git pull

cd src

./configure --enable-pythoninterp=yes --enable-python3interp=yes(支持python

make distclean  # if you build Vim before

修改Makefile

如下图所示打开448 450 行的注释行


make

sudo make install

执行

$vi --version | grep python

如下图所示:


6. 配置 Vundle:

6.1.下载 $ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

6.2 编辑 vim .vimrc

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') 
" let Vundle manage Vundle, required
 Plugin 'VundleVim/Vundle.vim' 
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
 Plugin 'L9'
" Git plugin not hosted on GitHub
 Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
"Plugin 'ascenator/L9', {'name': 'newL9'}
" 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


6.3 保存并退出

 6.4 install Install Plugins

  vim  .vimrc

 执行命令:PluginInstall

 或者在终端执行 vim +PluginInstall +qall

6.5 下载YouCompleteMe源码

  git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

  cd   ~/.vim/bundle/YouCompleteMe

#获取YCM的依赖包  

  git submodule update --init --recursive

#然后在在vimrc文件中加入

  Bundle 'Valloric/YouCompleteMe'  

 ./install.py --clang-completer 

执行完上述步骤就就已经安装完成自动补齐软件YouCompleteMe

如需要丰富功能如附加代码:

set  tabstop=4
set  softtabstop=4
set  shiftwidth=4
set  autoindent
set  cindent
set  nu
syntax on
set encoding=utf-8  
set fileencodings=utf-8,gbk,gb2312,gb18030,ucs-bom,latin1  
set tags=tags;  
set ts=4  
set vb t_vb=  
" When started as "evim", evim.vim will already have done these settings.  
if v:progname =~? "evim"  
  finish  
endif 
set nocompatible
set backspace=indent,eol,start    
set autoindent      " always set autoindenting on  
set nobackup        " do not keep a backup file, use versions instead  
  "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  
map Q gq  
if &t_Co > 2 || has("gui_running")  
  syntax on  
  set hlsearch  
endif
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")  
if has("cscope")  
    let current = "."  
     let num = 1  
	 while num < 20   
	   if filereadable(current . "/cscope.out")  
	      let $CSCOPE_DB = current . "/cscope.out"  
		  cs add $CSCOPE_DB  
		   break 
		else  
		  let current = current . "/.."  
		  let num = num + 1  
	   endif  
	endwhile  
endif  
syntax enable  
syntax on  
colorscheme desert  
filetype plugin indent on  
set completeopt=longest,menu 
set cst  
set csto=1  
set cscopequickfix=s-,c-,d-,i-,t-,e-,f-  
" cs add /home/yangxl/readcode/cscope-kernel/cscope.out  
" cs add /home/yangxl/readcode/cscope-app/cscope.out  
let Tlist_Enable_Fold_Column = 0  
let Tlist_WinWidth = 30  
let Tlist_Show_One_File = 1  
let g:miniBufExplMapCTabSwitchBufs = 1  
let g:miniBufExplMapWindowNavVim = 1  
let g:miniBufExplMapWindowNavArrows = 1  
let g:winManagerWindowLayout='FileExplorer|TagList'  
let g:SuperTabRetainCompletionType=2  
nmap wm :WMToggle<cr>  
set tabstop=4  
"nmap <F2> :cs find d <C-R><C-W><CR>  
"nmap <F3> :cs find c <C-R><C-W><CR>  
"nmap <F4> :cs find t <C-R><C-W><CR>  
"nmap <F5> :cs find e <C-R><C-W><CR>  
"nmap <F6> :cs find f <C-R><C-W><CR>  
"nmap <F7> :cs find i <C-R><C-W><CR>  
nmap <F5> :TlistToggle <CR>  
nmap <F2> :cs find c <C-R>=expand("<cword>")<CR><CR>  
nmap <F3> :cs find s <C-R>=expand("<cword>")<CR><CR>  
nmap <F4> :cs find g <C-R>=expand("<cword>")<CR><CR>  
nmap <F6> :cs find f   
nmap <C-n> :cn<CR>  
nmap <C-p> :cp<CR>  
"nmap  :cs find t <C-R>=expand("<cword>")<CR><CR>  
"nmap  :cs find e <C-R>=expand("<cword>")<CR><CR>  
"nmap  :cs find f <C-R>=expand("<cfile>")<CR><CR>  
"nmap  :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>  
"nmap  :cs find d <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>  
"nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>  
"nmap <F2> :scs find d <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space><C-Space>s  
        \:vert scs find s <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space><C-Space>g  
        \:vert scs find g <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space><C-Space>c  
        \:vert scs find c <C-R>=expand("<cword>")<CR><CR> 
"nmap <C-Space><C-Space>t  
        \:vert scs find t <C-R>=expand("<cword>")<CR><CR> 
"nmap <C-Space><C-Space>e  
        \:vert scs find e <C-R>=expand("<cword>")<CR><CR>  
"nmap <C-Space><C-Space>i  
        \:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> 
"nmap <F2>   
        \:vert scs find d <C-R>=expand("<cword>")<CR><CR>
set nu  
"set mouse=a  
set autoindent  
set cindent

filetype plugin indent on   
"打开文件类型检测, 加了这句才可以用智能补全  
set completeopt=longest,menu  
"新建.c,.h,.sh,.java文件,自动插入文件头   
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"  
""定义函数SetTitle,自动插入文件头   
func SetTitle()   
"如果文件类型为.sh文件   
if &filetype == 'sh'   
     call setline(1,"\#########################################################################")   
	 call append(line("."), "\# File Name: ".expand("%"))   
	 call append(line(".")+1, "\# Author: genglut")   
	 call append(line(".")+2, "\# Mail: genglut@163.com")   
	 call append(line(".")+3, "\# Created Time: ".strftime("%c"))   
	 call append(line(".")+4, "\#########################################################################") 
	 call append(line(".")+5, "\#!/bin/bash")   
	 call append(line(".")+6, "")   
else   
      call setline(1, "/*************************************************************************")   
	  call append(line("."), "    > File Name: ".expand("%"))   
	  call append(line(".")+1, "  > Author: genglut")   
	  call append(line(".")+2, "  > Mail: genglut@163.com")   
	  call append(line(".")+3, "  > Created Time: ".strftime("%c"))   
	  call append(line(".")+4, " ************************************************************************/")   
	  call append(line(".")+5, "")  
endif  
if &filetype == 'cpp' 
   call append(line(".")+6, "#include<iostream>")  
   call append(line(".")+7, "using namespace std;")  
   call append(line(".")+8, "")  
endif  
if &filetype == 'c'  
    call append(line(".")+6, "#include<stdio.h>")  
	call append(line(".")+7, "")  
 endif
 "新建文件后,自动定位到文件末尾  
autocmd BufNewFile * normal G  
endfunc   
"set shortmess=atI   " 启动的时候不显示那个援助乌干达儿童的提示    
winpos 5 5          " 设定窗口位置    
set lines=35 columns=100    " 设定窗口大小    
"  
set go=             " 不要图形按钮    
"color asmanian2     " 设置背景主题    
"set guifont=Courier_New:h10:cANSI   " 设置字体    
"syntax on           " 语法高亮    
"  
autocmd InsertLeave * se nocul  " 用浅色高亮当前行    
autocmd InsertEnter * se cul    " 用浅色高亮当前行   
set ruler           " 显示标尺    
set showcmd         " 输入的命令显示出来,看的清楚些    
set cmdheight=1     " 命令行(在状态行下)的高度,设置为1 
"set whichwrap+=<,>,h,l   " 允许backspace和光标键跨越行边界(不建议)    
"set scrolloff=3     " 光标移动到buffer的顶部和底部时保持3行距离    
"  
set novisualbell    " 不要闪烁(不明白)    
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}   "状态行显示的内容    
set laststatus=1    " 启动显示状态行(1),总是显示状态行(2)    
"set foldenable      " 允许折叠    
"set foldmethod=manual   " 手动折叠    
"set background=dark "背景使用黑色   
"  
set nocompatible  "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限    
" 显示中文帮助  
if version >= 603  
    set helplang=cn  
	set encoding=utf-8  
endif
" 设置配色方案  
colorscheme murphy  
"字体   
if (has("gui_running"))   
   set guifont=Bitstream\ Vera\ Sans\ Mono\ 10   
endif
nmap <leader>w :w!<cr>  
nmap <leader>f :find<cr>  
" 映射全选+复制 ctrl+a  
map <C-A> ggVGY  
map! <C-A> <Esc>ggVGY  
map <F12> gg=G  
" 选中状态下 Ctrl+c 复制  
vmap <C-c> "+y  
"去空行    
nnoremap <F2> :g/^\s*$/d<CR>   
"比较文件    
nnoremap <C-F2> :vert diffsplit   
"新建标签    
map <M-F2> :tabnew<CR>    
"列出当前目录文件    
map <F3> :tabnew .<CR>    
"打开树状文件目录    
map <C-F3> \be    
"C,C++ 按F5编译运行  
map <F5> :call CompileRunGcc()<CR>  
func! CompileRunGcc() 
 exec "w" 
 if &filetype == 'c'  
    exec "!g++ % -o %<"  
    exec "! ./%<"  
 elseif &filetype == 'cpp'  
     exec "!g++ % -o %<"  
	 exec "! ./%<"  
  elseif &filetype == 'sh'  
          :!./%  
  elseif &filetype == 'py'  
     exec "!python %"  
     exec "!python %<"  
 endif
endfunc 
"C,C++的调试  
map <F8> :call Rungdb()<CR>  
func! Rungdb()  
  exec "w"  
  exec "!g++ % -g -o %<"  
  exec "!gdb ./%<"  
endfunc  
	   



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值