From Vim Tips Wiki
Jump to: navigation, search
Please review this tip:
This tip was imported from vim.org and needs general review.
You might clean up comments or merge similar tips.
Add suitable categories so people can find the tip.
Please avoid the discussion page (use the Comments section below for notes).
If the tip contains good advice for current Vim, remove the {{review}} line.
Tip 1439 Previous Next created December 12, 2006 · complexity basic · author Johnny · version n/a
I've read a lot of tips about how to make Vim as an IDE like editor. Most of them are really useful, and I want to sum up them in this tip, and then add some of my experiences.
Here are some useful tips to read:
VimTip64 Always set your working directory to the file you're editing Vim online
VimTip58 Switching back and forth between ViM and Visual Studio _NET Vim online
VimTip1119 How to use Vim like an IDE Vim online
Here are some scripts I recommend:
Project 1.1.4 Organize/navigate projects of files (like IDE/buffer explorer).
TagList 4.2 Source code browser (supports C/C++, Java, Perl, Python, TCL, SQL, PHP, etc).
MiniBufExpl 6.3.2 Elegant buffer explorer; takes very little screen space.
ShowMarks-2.2 Visually shows the location of marks.
OmniCppComplete-0.4 C/C++ omni-completion with ctags database.
CRefVim-1.0.4 A C-reference manual especially designed for Vim.
exUtility-4.1.0 Global search,symbol search,tag track...(Like IDE/Source Insight).
Here are some programs you may need to download:
http://gnuwin32.sourceforge.net/
diffutils-2.8.7-1.exe
gawk-3.1.3-2.exe
id-utils-4.0-2.exe
http://ctags.sourceforge.net/
ctags.exe
Here are some scripts for your vimrc: " --------------------
" ShowMarks
" --------------------
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
let g:showmarks_enable = 1
" For marks a-z
highlight ShowMarksHLl gui=bold guibg=LightBlue guifg=Blue
" For marks A-Z
highlight ShowMarksHLu gui=bold guibg=LightRed guifg=DarkRed
" For all other marks
highlight ShowMarksHLo gui=bold guibg=LightYellow guifg=DarkYellow
" For multiple marks on the same line.
highlight ShowMarksHLm gui=bold guibg=LightGreen guifg=DarkGreen
" --------------------
" Project
" --------------------
map
map
nmap
let g:proj_window_width = 30
let g:proj_window_increment = 50
" --------------------
" exTagSelect
" --------------------
nnoremap
nnoremap
nnoremap
map
map
let g:exTS_backto_editbuf = 0
let g:exTS_close_when_selected = 1
" --------------------
" exGlobalSearch
" --------------------
nnoremap
nnoremap
nnoremap
nnoremap
map
map
let g:exGS_backto_editbuf = 0
let g:exGS_close_when_selected = 0
" --------------------
" exSymbolTable
" --------------------
nnoremap
nnoremap
nnoremap
nnoremap
nnoremap
let g:exSL_SymbolSelectCmd = 'TS'
" --------------------
" exEnvironmentSetting
" --------------------
function g:exES_UpdateEnvironment()
if exists( 'g:exES_PWD' )
silent exec 'cd ' . g:exES_PWD
endif
if exists( 'g:exES_Tag' )
let &tags = &tags . ',' . g:exES_Tag
endif
if exists( 'g:exES_Project' )
silent exec 'Project ' . g:exES_Project
endif
endfunction
" --------------------
" TagList
" --------------------
" F4: Switch on/off TagList
nnoremap
" TagListTagName - Used for tag names
highlight MyTagListTagName gui=bold guifg=Black guibg=Orange
" TagListTagScope - Used for tag scope
highlight MyTagListTagScope gui=NONE guifg=Blue
" TagListTitle - Used for tag titles
highlight MyTagListTitle gui=bold guifg=DarkRed guibg=LightGray
" TagListComment - Used for comments
highlight MyTagListComment guifg=DarkGreen
" TagListFileName - Used for filenames
highlight MyTagListFileName gui=bold guifg=Black guibg=LightBlue
"let Tlist_Ctags_Cmd = $VIM.'/vimfiles/ctags.exe' " location of ctags tool
let Tlist_Show_One_File = 1 " Displaying tags for only one file~
let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
let Tlist_Use_Right_Window = 1 " split to the right side of the screen
let Tlist_Sort_Type = "order" " sort by order or name
let Tlist_Display_Prototype = 0 " do not show prototypes and not tags in the taglist window.
let Tlist_Compart_Format = 1 " Remove extra information and blank lines from the taglist window.
let Tlist_GainFocus_On_ToggleOpen = 1 " Jump to taglist window on open.
let Tlist_Display_Tag_Scope = 1 " Show tag scope next to the tag name.
let Tlist_Close_On_Select = 1 " Close the taglist window when a file or tag is selected.
let Tlist_Enable_Fold_Column = 0 " Don't Show the fold indicator column in the taglist window.
let Tlist_WinWidth = 40
" let Tlist_Ctags_Cmd = 'ctags --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++'
" very slow, so I disable this
" let Tlist_Process_File_Always = 1 " To use the :TlistShowTag and the :TlistShowPrototype commands without the taglist window and the taglist menu, you should set this variable to 1.
":TlistShowPrototype [filename] [linenumber]
" --------------------
" MiniBufExpl
" --------------------
let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines)
let g:miniBufExplModSelTarget = 1 " If you use other explorers like TagList you can (As of 6.2.8) set it at 1:
let g:miniBufExplUseSingleClick = 1 " If you would like to single click on tabs rather than double clicking on them to goto the selected buffer.
let g:miniBufExplMaxSize = 1 "
"let g:miniBufExplForceSyntaxEnable = 1 " There is a Vim bug that can cause buffers to show up without their highlighting. The following setting will cause MBE to
"let g:miniBufExplorerMoreThanOne = 1 " Setting this to 0 will cause the MBE window to be loaded even
"let g:miniBufExplMapCTabSwitchBufs = 1
"let g:miniBufExplMapWindowNavArrows = 1
"for buffers that have NOT CHANGED and are NOT VISIBLE.
highlight MBENormal guibg=LightGray guifg=DarkGray
" for buffers that HAVE CHANGED and are NOT VISIBLE
highlight MBEChanged guibg=Red guifg=DarkRed
" buffers that have NOT CHANGED and are VISIBLE
highlight MBEVisibleNormal term=bold cterm=bold gui=bold guibg=Gray guifg=Black
" buffers that have CHANGED and are VISIBLE
highlight MBEVisibleChanged term=bold cterm=bold gui=bold guibg=DarkRed guifg=Black
" --------------------
" OmniCppComplete
" --------------------
" set Ctrl+j in insert mode, like VS.Net
imap
" :inoremap
" set completeopt as don't show menu and preview
set completeopt=menuone
" Popup menu hightLight Group
highlight Pmenu ctermbg=13 guibg=LightGray
highlight PmenuSel ctermbg=7 guibg=DarkBlue guifg=White
highlight PmenuSbar ctermbg=7 guibg=DarkGray
highlight PmenuThumb guibg=Black
" use global scope search
let OmniCpp_GlobalScopeSearch = 1
" 0 = namespaces disabled
" 1 = search namespaces in the current buffer
" 2 = search namespaces in the current buffer and in included files
let OmniCpp_NamespaceSearch = 1
" 0 = auto
" 1 = always show all members
let OmniCpp_DisplayMode = 1
" 0 = don't show scope in abbreviation
" 1 = show scope in abbreviation and remove the last column
let OmniCpp_ShowScopeInAbbr = 0
" This option allows to display the prototype of a function in the abbreviation part of the popup menu.
" 0 = don't display prototype in abbreviation
" 1 = display prototype in abbreviation
let OmniCpp_ShowPrototypeInAbbr = 1
" This option allows to show/hide the access information ('+', '#', '-') in the popup menu.
" 0 = hide access
" 1 = show access
let OmniCpp_ShowAccess = 1
" This option can be use if you don't want to parse using namespace declarations in included files and want to add namespaces that are always used in your project.
let OmniCpp_DefaultNamespaces = ["std"]
" Complete Behaviour
let OmniCpp_MayCompleteDot = 0
let OmniCpp_MayCompleteArrow = 0
let OmniCpp_MayCompleteScope = 0
" When 'completeopt' does not contain "longest", Vim automatically select the first entry of the popup menu. You can change this behaviour with the OmniCpp_SelectFirstItem option.
let OmniCpp_SelectFirstItem = 0
After setting this, now you can really using Vim as an IDE-like editor.
I usually like to create project use exUtility, use "gvim project_name.vimenvironment"
You can browse project file by Project-plugin.
You can global search and edit them by exUtility-plugin.
You can jump tag and track code by exUtility-plugin.
You can analysis code by taglist-plugin.
You can choose buffer by minibuffer-plugin.
You can set clear mark by showmark-plugin.
edit Comments
I think cscope should also have been on this list, especially for people who are editing C files (as opposed to C++, which seems to be the main focus of this tip). It has a lot more features than ctags. A nice tutorial can be found at cscope.sourceforge.net.
For real-time source code analysis, this plugin might help as well: http://www.vim.org/scripts/script.php?script_id=2368
No comments:
Post a Comment