Make Vim an IDE

Making vim an IDE is an exiting thing. Conside following configuration files:

  • .vimrc: ~/.vimrc
  • winmanager.vim: ~/.vim/bundle/winmanager/plugin/winmanager.vim

.vimrc

my .vimrc is as follows:

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()

" let Vundle manage Vundle, required
Plugin ‘VundleVim/Vundle.vim‘

" My Bundles here
"
" original repos on github
Bundle ‘tpope/vim-fugitive‘
Bundle ‘Lokaltog/vim-easymotion‘
Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}
Bundle ‘tpope/vim-rails.git‘
Bundle ‘The-NERD-tree‘
Bundle ‘The-NERD-Commenter‘
Bundle ‘taglist.vim‘
Bundle ‘winmanager‘

" vim-scripts repos
Bundle ‘L9‘
Bundle ‘FuzzyFinder‘

" non github repos
Bundle ‘git://git.wincent.com/command-t.git‘
Bundle ‘bufexplorer.zip‘

" Color schemes
Bundle ‘tomasr/molokai‘
Bundle ‘flazz/vim-colorschemes‘
Bundle ‘evening_2‘
Bundle ‘Solarized‘

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

" 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
"
" Put your non-Plugin stuff after this line

" Set <leader> to ‘,‘
let mapleader = ‘,‘

" Set color scheme
syntax on
" colorscheme molokai
colorscheme evening_2
" syntax enable
" set background=dark
" colorscheme solarized

" To change the number of space characters inserted for indentation
set shiftwidth=4
" To control the number of space characters that will be inserted when the tab key is pressed
" insert 4 spaces for a tab
set tabstop=4
" To insert space characters whenever the tab key is pressed
" if you want to enter a real tab character, use Ctrl-V<Tab> key sequence
set expandtab
" To display line numbers
set nu
" By pressing Ctrl-N twice in normal mode,
" Vim toggles between showing and hiding line numbers.
nmap <C-N><C-N> :set invnumber<CR>
" make backspace work like most other apps
set backspace=2
" To display the status line always
set laststatus=2
" Do not create an swapfile
set noswapfile

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Cscope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" This tests to see if vim was configured with the ‘--enable-cscope‘ option
" when it was compiled.  If it wasn‘t, time to recompile vim...
if has("cscope")
    " use both cscope and ctag for ‘ctrl-]‘, ‘:ta‘, and ‘vim -t‘
    set cscopetag

    " check cscope for definition of a symbol before checking ctags: set to 1
    " if you want the reverse search order.
    set csto=0

    " add any cscope database in current directory
    if filereadable("cscope.out")
        cs add cscope.out
    " else add the database pointed to by environment variable
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB
    endif

    " show msg when any other cscope db added
    set cscopeverbose  

    "‘‘‘‘‘‘‘‘‘‘ My cscope/vim key mappings
    "
    " The following maps all invoke one of the following cscope search types:
    "
    "   ‘s‘   symbol: find all references to the token under cursor
    "   ‘g‘   global: find global definition(s) of the token under cursor
    "   ‘c‘   calls:  find all calls to the function name under cursor
    "   ‘t‘   text:   find all instances of the text under cursor
    "   ‘e‘   egrep:  egrep search for the word under cursor
    "   ‘f‘   file:   open the filename under cursor
    "   ‘i‘   includes: find files that include the filename under cursor
    "   ‘d‘   called: find functions that function under cursor calls
    "
    " Below are three sets of the maps: one set that just jumps to your
    " search result, one that splits the existing vim window horizontally and
    " diplays your search result in the new window, and one that does the same
    " thing, but does a vertical split instead (vim 6 only).
    "
    " To do the first type of search, hit ‘CTRL-\‘, followed by one of the
    " cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope
    " search will be displayed in the current window.  You can use CTRL-T to
    " go back to where you were before the search.
    nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>

    " Using ‘CTRL-spacebar‘ (intepreted as [email protected] by vim) then a search type
    " makes the vim window split horizontally, with search result displayed in
    " the new window.
    nmap <[email protected]>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]>g :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]>t :cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]>e :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <[email protected]>i :cs find i <C-R>=expand("<cfile>")<CR><CR>
    nmap <[email protected]>d :cs find d <C-R>=expand("<cword>")<CR><CR>

    " Hitting CTRL-space *twice* before the search type does a vertical
    " split instead of a horizontal one (vim 6 and up only)
    "
    " (Note: you may wish to put a ‘set splitright‘ in your .vimrc
    " if you prefer the new window on the right instead of the left
    nmap <[email protected]><[email protected]>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]><[email protected]>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]><[email protected]>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]><[email protected]>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]><[email protected]>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <[email protected]><[email protected]>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <[email protected]><[email protected]>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <[email protected]><[email protected]>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Taglist
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Specifies the path to the ctags utility
" let Tlist_Ctags_Cmd = ‘/usr/bin/ctags‘

" Increase the Vim window width to accommodate the taglist window
let Tlist_Inc_Winwidth = 0

" Jump to taglist window on open
let Tlist_GainFocus_On_ToggleOpen = 1

" Open the taglist window when Vim starts
let Tlist_Auto_Open = 1

" Automatically update the taglist to include
" newly edited files
let Tlist_Auto_Update = 1

" Close Vim if the taglist is the only window
let Tlist_Exit_OnlyWindow = 1

" Show tags for the current buffer only
let Tlist_Show_One_File = 1

" Process files even when the taglist window is closed
let Tlist_Process_File_Always = 1

" Display the tags menu
let Tlist_Show_Menu = 1

" Place the taglist window on the right side
let Tlist_Use_Right_Window = 1

" Automatically highlight the current tag in the taglist
let Tlist_Auto_Highlight_Tag = 0

nmap <silent> <leader>tg :TlistToggle<CR>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" WinManager
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Using ‘,wm‘ to open or close WinManage in normal mode
nmap <silent> <leader>wm :WMToggle<CR>

let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout=‘NERDTree|BufExplorer,TagList‘

function! NERDTree_Start()
    exec ‘NERDTree‘
endfunction

function! NERDTree_IsValid()
    return 1
endfunction

" Auto open WinManager
let g:AutoOpenWinManager=1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Main points of my vimrc

  • Use vundle to manage plugins;
  • Key pulgins: winmanager, taglist, nerdtree.

To use my vimrc

  1. copy my vimrc to your .vimrc
  2. open vim and execute command “: PluginInstall”
  3. Modify winmanager.vim

Modify winmanager.vim

Modify function ToggleWindowsManager

" toggle showing the explorer plugins.
function! <SID>ToggleWindowsManager()
    if IsWinManagerVisible()
        call s:CloseWindowsManager()
    else
        call s:StartWindowsManager()
        " Solve the bug that
        " an extra blank window will open
        " when WinManager opens
        exec ‘q‘
    end
endfunction

Add codes to set auto open WinManager

"set auto open WinManager
if g:AutoOpenWinManager
    autocmd VimEnter * nested call s:ToggleWindowsManager()|1wincmd w
end

时间: 2024-10-12 20:48:48

Make Vim an IDE的相关文章

vim变ide

如果你稍微写过一点代码,就能知道“集成开发环境”(IDE)是多么的便利.不管是Java.C还是Python,当IDE会帮你检查语法.后台编译,或者自动导入你需要的库时,写代码就变得容易许多.另外,如果你工作在Linux上,你也会知道Vim在进行文本编辑的时候是多么的方便.所以,你可能会想从Vim中也获取这些IDE特性. 事实上,很少有方法可以帮你做到.有些人可能会想到试着把Vim打造成C语言IDE的,比如c.vim:也有把Vim集成到Eclipse里的 Eclim .但是我想要告诉你的是一个更加

使用VIM打造IDE(针对C语言)

=============================== 话不多说,先来看看效果 =============================== ================================ 使用vim打造IDE, 针对C语言开发者 建议使用gvim ================================ # 安装ruby, command-t插件会用到 sudo apt install ruby ruby-dev # 安装vim, vim-gtk sudo

vim打造IDE

1.首先安装插件管理器 Pathogen Install to ~/.vim/autoload/pathogen.vim mkdir -p ~/.vim/autoload ~/.vim/bundle && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim 在Centos家目录中新建.vimrc文件,添加: execute pathogen#infect() syntax on filetype plugi

草稿-把vim变成IDE

从昨天下午到现在一直在研究vim,初学者,从vim最基本的命令开始看起的.是通过vimtutor学习的. 看到最后一章的时候,发现原来vimtutor中的知识知识vim中的冰山一角,vim真正的强大之处就是在于程序员可以随心所欲地配置它,使它易于自己使用.据说牛逼的人配置出来的比IDE还要方便使用. 之后再网上看配置vim的方法,有很多文章中提到用Autocomplpop.ctags.OmniCppComplete这三个东西,就可以简单地讲vim配置成类似IDE环境(虽然还比不上IDE,但笔记在

Vim配置IDE开发环境

我的vim IDE界面: 1.安装Vim和Vim基本插件首先安装好Vim和Vim的基本插件.这些使用apt-get安装即可:[email protected]:~/arm$sudo apt-get install vim vim-scripts vim-doc其中vim-scripts是vim的一些基本插件,包括语法高亮的支持.缩进等等.vim中文帮助文档tar包下载地址:http://sourceforge.net/projects/vimcdoc/files/vimcdoc/解压后其中有个d

vim变身IDE

原文出处: xmodulo   译文出处:LCTT - love_daisy_love 如 果你稍微写过一点代码,就能知道“集成开发环境”(IDE)是多么的便利.不管是Java.C还是Python,当IDE会帮你检查语法.后台编 译,或者自动导入你需要的库时,写代码就变得容易许多.另外,如果你工作在Linux上,你也会知道Vim在进行文本编辑的时候是多么的方便.所以,你可 能会想从Vim中也获取这些IDE特性. 事实上,很少有方法可以帮你做到.有些人可能会想到试着把Vim打造成C语言IDE的,比

如何用Vim搭建IDE?

转自:http://harttle.com/2015/11/04/vim-ide.html 一年前我从Vim切换到了WebStorm,是因为WebStorm强大的重构功能,以及Super Search功能.涉及多文件编辑和重构时WebStorm的优势便非常明显. 最近到手了HHKB,从键盘到触摸板的切换还是挺麻烦的,于是Vim编辑的需求又来了..加之WebStorm经常假死,我决定重新启用Vim.同时重新打造了我的Vim,使它能够满足我在IDE中的所有需求.这篇文章便来记述整个过程,或许有些帮助

将vim变为IDE(不定期更新)

今天重新配置了一下vim,将其配置成为了一个完整的IDE.包括自动补全,文件列表,函数列表等 先来一张图: 以下是文件配置: set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示 set nu " 显示行号 syntax on " 语法高亮 set ruler " 显示标尺 set showmode set showcmd set hlsearch set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的

让vim成为ide

gvim的tabe标签页打开跟在同一个页面(标签中)打开,对buffer的影响都是一样的,都是增加新的buffer 可以认为gvim的命令行模式跟bash shell里的操作差不多 在命令行模式中通过!comm可以执行shell命令, 甚至完全从vim切换到shell,使用命令:shell,退回用exit vim和shell命令之间交换数据: r !comm 在当前行的下一行添加命令comm执行结果 3 !comm, 1,3 !comm:  将3行或1-3行的内容输入到comm命令中并用命令结果