Ubuntu 环境下 vim 打造成 IDE

  1. 入门用这个教程
    一个小博客教你把vim用飞起来 - 逝雪 - 博客园 http://www.cnblogs.com/songfy/p/5635757.html

配置基本的展示形态

首先, 我们建立目录存放我们的主题

 mkdir -p  ~/.vim/colors

这个目录就是给我们存放主题用的, 我们用什么主题呢? 这里我们采用molokai这个主题, 当然如果读者愿意用别的主题,
也是可以的, 下一个就行.

http://www.vim.org/scripts/script.php?script_id=2340
下载molokai主题, 拷贝到~/.vim/colors目录下, 创建.vimrc文件.

touch ~/.vimrc

然后打开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'

" nerdtree插件
Plugin 'scrooloose/nerdtree'

" tagbar
Plugin 'majutsushi/tagbar'

" auto pair
Plugin 'jiangmiao/auto-pairs'

" mini buffer
Plugin 'minibufexpl.vim'

" tag list
Plugin 'taglist.vim'

" nerd commit
Plugin 'scrooloose/nerdcommenter'

" PHP mannual
Plugin 'alvan/vim-php-manual'

" snippets mate
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'

" markdown插件
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'

" you complete me插件
Plugin 'Valloric/YouCompleteMe'

" 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

set modelines=0

"设置更好的删除
set backspace=2

syntax on "语法高亮

"用浅色高亮当前行
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul

set smartindent "智能对齐

set autoindent "自动对齐

set confirm "在处理未保存或只读文件的时候,弹出确认框

set tabstop=4 "tab键的宽度
set softtabstop=4
set shiftwidth=4 "统一缩进为4
set expandtab "不要用空格替代制表符

set number "显示行号
set history=50  "历史纪录数
set hlsearch
set incsearch "搜素高亮,搜索逐渐高亮

set gdefault "行内替换
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936,utf-16,big5,euc-jp,latin1 "编码设置

colorscheme molokai

set guifont=Menlo:h16:cANSI "设置字体
set langmenu=zn_CN.UTF-8
set helplang=cn  "语言设置

set ruler "在编辑过程中,在右下角显示光标位置的状态行

set laststatus=1  "总是显示状态行

set showcmd "在状态行显示目前所执行的命令,未完成的指令片段也会显示出来

set scrolloff=3 "光标移动到buffer的顶部和底部时保持3行的距离
set showmatch "高亮显示对应的括号
set matchtime=5 "对应括号高亮时间(单位是十分之一秒)

set wildmenu  "增强模式中的命令行自动完成操作

set linespace=2 "字符间插入的像素行数目
set whichwrap=b,s,<,>,[,] "开启normal 或visual模式下的backspace键空格键,左右方向键,insert或replace模式下的左方向键,右方向键的跳行功能

filetype plugin indent on "分为三部分命令:file on,file plugin on,file indent on 分别是自动识别文件类型, 用用文件类型脚本,使用缩进定义文件


syntax enable
set foldenable  "允许折叠
set cursorline "突出显示当前行
set magic  "设置魔术?神马东东
set ignorecase "搜索忽略大小写
filetype on "打开文件类型检测功能
set background=dark
set t_Co=256   "256色
set mouse=a  "允许鼠标
"使用语法高亮定义代码折叠
set foldmethod=syntax
""打开文件是默认不折叠代码
set foldlevelstart=99"

" nerdtree 配置
let NERDTreeQuitOnOpen=1 "打开文件时关闭树
let NERDTreeShowBookmarks=1 "显示书签

" taglist 配置
let Tlist_Use_Right_Window=1 "taglist 显示在右侧 
let Tlist_Exit_OnlyWindow=1 "taglist 只剩下一个窗口时,自动关闭
let Tlist_File_Fold_Auto_Close=1

" -- MiniBufferExplorer --   
let g:miniBufExplMapWindowNavVim = 1  " 按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口  
let g:miniBufExplMapWindowNavArrows = 1  "按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口  
let g:miniBufExplMapCTabSwitchBufs = 1 "启用以下两个功能:Ctrl+tab移到下一个buffer并在当前窗口打开;Ctrl+Shift+tab移到上一个buffer并在当前窗口打开;ubuntu好像不支持  
let g:miniBufExplMapCTabSwitchWindows = 1 "  启用以下两个功能:Ctrl+tab移到下一个窗口;Ctrl+Shift+tab移到上一个窗口;ubuntu好像不支持  
let g:miniBufExplModSelTarget = 1     " 不要在不可编辑内容的窗口(如TagList窗口)中打开选中的buffer

" markdown 配置
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
let g:vim_markdown_json_frontmatter = 1

" YouCompleteMe配置
let g:ycm_key_list_select_completion = ['<Down>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0  " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1    " 语法关键字补全
" 在注释输入中也能补全
let g:ycm_complete_in_comments = 1
" 在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

let mapleader = ","
map <leader>ne :NERDTreeToggle<CR>
nmap <leader>tb :TagbarToggle<CR>
nmap <leader>mmbe :MiniBufExplorer<CR>
nmap <leader>mmbc :CMiniBufExplorer<CR>
nmap <leader>mmbu :UMiniBufExplorer<CR>
nmap <leader>mmbt :TMiniBufExplorer<CR>
map <leader>tl :TlistToggle<cr>
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>ma :set mouse=a<cr>
nnoremap <leader>mu :set mouse=<cr>
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
nnoremap <leader>lo :lopen<CR> "open locationlist                                                                                                                      
nnoremap <leader>lc :lclose<CR>   "close locationlist
inoremap <leader><leader> <C-x><C-o>"
inoremap <leader><leader> <C-x><C-o>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>

"对搜索的设置
map ft :call Search_Word()<CR>:copen<CR>
function Search_Word()
let w = expand("<cword>") " 在当前光标位置抓词
execute "vimgrep " . w . " %"
endfunction

2.好,这时候就已经代码高亮并且上色了
但是启动vim时,终端显示
Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.
YouCompleteMe unavailable: requires Vim 7.4.143+

3.针对Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.
vim配制方法原始人类新浪博客 http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380147d8c8c4668d4e419ce3b4c413037bfa6663f405a8e906b6075a84f5deaa43024630123b5989fd51288ac925f75ce786a6459db0144dc4ee58c16728173cc1cfeaf68b6fca367d2b9d2a2c85422dd527520c6b6c94d0164dd6e83033192b19939025e60ebab6330be4e7659882337a14689a1667906f1e1dd2b5bc25a8c365780af44a73e63a212d443466253a03de555167a66f74f56a4182a04e3a90ea1706e4153a148c4aec1c7a916cb89b16d8ffabaf46e82609799b7bf6642010ca776e8fc&p=9d769a47ba9506bc18bd9b7e0e1d86&newp=882a9546dd8559be18acd02d0214a5231610db2151d7db126b82c825d7331b001c3bbfb423231b05d3cf7c6507ab4c5decf437703c0021a3dda5c91d9fb4c57479ce3f25305dc2&user=baidu&fm=sc&query=Exuberant+ctags+%28http%3A//ctags%2Esf%2Enet%29+not+found+in+PATH%2E+Plugin+is+not+loaded%2E&qid=a4630e2f00013453&p1=9

安装ctags
vim插件ctags的安装和使用 - G_BrightBoy的专栏 - 博客频道 - CSDN.NET http://blog.csdn.net/g_brightboy/article/details/16830395

sudo apt-get install ctags (ubuntu)

解压后
$ cd ctags-5.8
$ ./configure
$ make
# make install
安装结束后,使用ctags命令测试是否成功
或whatis ctags, whereis ctags等

4.升级vim

Linux升级Vim 8.0如虎添翼 - Linux运维的博客 - 博客频道 - CSDN.NET http://blog.csdn.net/linuxnews/article/details/52938583

虽然 Vim 8.0 已经正式发布,但要进入各大 Linux 发行版的官方源还需要很长一段时间。幸运的是,已经有人为 Ubuntu 和其衍生版本制作了非官方 PPA 进行安装,不过此种方法有风险,建议大家只用于测试环境。

sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim

5.此时输入vim,提示
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support

解决办法
Ubuntu 14.04中vim配置Python开发环境_百度经验 http://jingyan.baidu.com/article/0320e2c1cd6f021b87507b86.html

vim 插件 youcompleteme full install - conding_算子 - 博客频道 - CSDN.NET http://blog.csdn.net/u012675539/article/details/51489957

将你的Vim 打造成轻巧强大的IDE - 乐正 http://yuez.me/jiang-ni-de-vim-da-zao-cheng-qing-qiao-qiang-da-de-ide/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值