Using VIM to build the IDE (for C language)

Source: Internet
Author: User
Tags autoload create directory gtk

===============================

Talk not much, first to see the effect

===============================



================================
Use Vim to create Ides for C language developers
Recommended use of Gvim
================================

# To install Ruby, the Command-t plugin will use
sudo apt install ruby Ruby-dev

# Install VIM, VIM-GTK
sudo apt install vim vim-gtk

# Create the. VIMRC in the home directory and edit
1. Copy the contents of VIMRC in Appendix 1

# Create a. Vim directory in the home directory
1. Enter the. Vim Directory
2. Create directory AutoLoad Bundle colors syntax

# Create Mycolor.vim in the ~/.vim/colors directory and edit
1. Copy the contents of Mycolor.vim in Appendix 2

# Create C.vim in the ~/.vim/syntax directory and edit
1. Copy the contents of C.vim in Appendix 3

# Download Plugin vundle to ~/.vim/bundle
1. Git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/vundle.vim
2. Need to install Git
3. Vundle can automatically install and update other VIM plugins

# download plugin pathogen to ~/.vim/autoload
1. Curl-lsso ~/.vim/autoload/pathogen.vim Https://tpo.pe/pathogen.vim
2. Need to install Curl
3. Pathogen can automatically load plug-ins

# Install the rest of the vim plugin
1. Open Vim or Gvim
2. Execution:P Lugininstall

# Compile Command-t Plugin
1. Enter the ~/.VIM/BUNDLE/COMMAND-T/RUBY/COMMAND-T directory
2. Execute Ruby EXTCONF.RB
3. Execute make

# Compile Youcompleteme Plugin
1. Enter ~/.vim/bundle/youcompleteme
2. Implementation./install.py--clang-completer
3. Need to install CMake

# Install Ctags
1.: http://ctags.sourceforge.net/

# Install Cscope
1.: http://cscope.sourceforge.net/
2. Modify the source code so that it supports the soft link of the recursive Search Folder
Modified files: dir.c
How to modify: Replace function call Lstat all to stat
3. Compile the source code may appear error
Error: Fatal error:curses.h:no such file or directory
FIX: sudo apt install libncurses5-dev libncursesw5-dev


# Create tag build and highlight scripts
1. Find a place to create the htags.sh file, and note that the path to the script is also modified at the same time. VIMRC
2. Copy the contents of htags.sh in Appendix 4
3. Add execution privileges to htags.sh chmod u+x htags.sh

# Generate labels for ctags and Cscope and highlight
1. Open Gvim or Vim in the project's root directory
2. Use the shortcut key \BT to create a ctags label
3. Use the shortcut key \BC to create a cscope label
4. Use the quick see \ht to re-highlight the label
* Each time you start vim, it will be imported automatically once, if not
Do not re-import the label again

# Use Youcompleteme's auto-completion function
1. In the root directory of the project or create a. ycm_extra_conf.py
2. Copy the contents of the. ycm_extra_conf.py in Appendix 5
3. Modify the header file path according to the project



Appendix 1. VIMRC

"=================== Universal Configuration ======================" File search path set Path=.,/usr/include, "control set nocompatible" Turn off VI compatible FIL EType off "Close file type detection, Vundle need set FILEENCODINGS=UTF-8,GBK" GBK on "using Utf-8 or syntax encoding                  Syntax highlighting set backspace=2 "backspace normal mode set whichwrap=<,>,[,]" when the cursor is to the beginning or end of the line, allow left and right arrow keys to wrap the set Autoread "File modified outside of VIM, auto reload set Nobackup" Do not use Backup set confirm "when processing unsaved or read-only files, pop-up confirmation message set S Crolloff=3 "cursor moves to the top or bottom of the distance to roll to the distance set history=1000" Number of history set mouse= "Off Mouse Set sel Ection=inclusive "Select Include last Character set Selectmode=mouse,key" Start selection mode set Completeopt=longest,menu "Smart completion, popup menu, no ambiguity when automatically Populate set Noswapfile "Close Interchange File Set hidden" allows you to toggle the buffer "Show ColorScheme MyColor" selection when there are unsaved modifications Color scheme Set t_co=256 "number of colors can be used set numbers" display line numbers set laststatus=2 "Show status line set Rul ER "Show Ruler set showcmd "Show input command set Showmatch" highlight bracket match set matchtime=1 "match bracket highlight time (very      One second) set matchpairs={:}, (:) "Match bracket" {} "" () "Set Hlsearch" when retrieving a highlight match set Incsearch "Edge Search edge display match set go-=t"                 Remove gvim Toolbar "format set Noexpandtab" Do not convert the tab to a space set shiftwidth=4 "automatically indents the distance, is also the distance of the translation character set tabstop=4 "Tab key space number set Autoindent" Auto indent set smartindent "smart indent" =================== key map = = ==================== "key map start character let Mapleader = ' \ '" Toggle tab with Ctrl-l and ctrl+h nnoremap <C-l> gt n Noremap <c-h> GT "Add semicolons at the end of the line Nnoremap <silent> <Leader>; :<esc><end>a<space>;<esc><down> "Save Nnoremap <C-s>:w<cr>" Replace Nnoremap < C-h>:%s/<c-r>=expand ("<cword>") <cr>/<c-r>=expand ("<cword>") <CR> "======= ============ plugin management ====================== "Download Vundle" git clone https://github.com/vundlevim/vundle.vim.git ~/.vim/bundle/vundle.vim "Download Pathogen" Curl-lsso ~/.vim/autoload/ Pathogen.vim Https://tpo.pe/pathogen.vim "Add Vundle to runtime Pathset Rtp+=~/.vim/bundle/vundle.vim" Download the plugin to the bundle directory call Vundle#begin () "Plugin on GitHub repoplugin ' vundlevim/vundle.vim ' plugin ' scrooloose/ Nerdtree ' Plugin ' lokaltog/vim-powerline.git ' Plugin ' wincent/command-t ' Plugin ' valloric/youcompleteme ' Plugin ' Tomtom/tlib_vim ' Plugin ' Tomtom/viki_vim ' "Plugin from Http://vim-scripts.org/vim/scripts.htmlPlugin ' Taglist.vim ' Plugin ' easygrep ' git Plugin not hosted on GitHub "Plugin ' git://... '" Git repos on your local machine "Plugin ' file://". .' Call Vundle#end () filetype plugin indent on "required" =================== plug-in configuration ====================== "----- Pathogen-----Execute pathogen#infect () "-----nerdtree-----Let G:nerdtreecasesensitivesort = 1let g:nerdtreewinsize = 25let G:nerdtreewinpos = "Right" Nnoremap <silent> <Leader>t:NERDTreeToggle<CR> nnoremap <silent > <Leader>o:NERDTreeFind<CR> "-----Powerline-----Set Fillchars+=stl:\, stlnc:let g:powerline_symbols = ' Compatible ' let G:powerline_stl_path_style = ' filename ' "Show file name only"-----command-t-----Let G:commandtfilescanner = ' ruby ' Use Ruby as the file browser let g:commandttraversescm = ' dir ' "root directory for Vim to be performed" Open file jump Nnoremap <silent> <leader>f:comman         Dt<cr> "-----taglist-----Let Tlist_show_one_file = 1" shows only taglistlet Tlist_exit_onlywindow = 1 of the current file "TagList is the last window when exiting Vimlet Tlist_use_left_window = 1" In the left window shows taglistlet tlist_gainfocus_on_toggleopen = 1 "Open taglist  When the cursor stops in the taglist window let tlist_auto_update = 1 "Auto Update" opens the tag browser nnoremap <silent><Leader>dt:Tlist<CR> " Regenerate label Nnoremap &LT;SILENT&GT;&LT;LEADER&GT;BT:!~/myfiles/tool/sh/ctags/hitags.sh<cr> "highlight label Nnoremap < Silent><leader>ht:so tags.vim<cr> "-----cscope-----" Load Cscope Library if filereadable ("Cscope.out") CS add Cscope.outendifset cscopequickfix=s-,c-,d-,i-,t-,e-"Use Quickfix window to display results set CST" Jump also use Cscope Library "Open Reference window Nnoremap <silent><Leader>cw:cw< Cr> "Rebuild index file Nnoremap <silent><leader>bc:!cscope-rbq<cr>" s: find this C symbol "G: find this definition" D: find function called by this function "C: Find the function called this function "T: Find this string" E: Find this egrep mode "F: Find this file" I: Find the file containing this file Nnoremap <c-\>s:scs find <c-r>=expand ("< Cword> ") <cr><cr>nnoremap <c-\>g:scs Find G <c-r>=expand (" <cword> ") <CR>< Cr>nnoremap <c-\>c:scs Find C <c-r>=expand ("<cword>") <cr><cr>nnoremap <C-\>t : SCS Find T <c-r>=expand ("<cword>") <cr><cr>nnoremap <c-\>e:scs find e <c-r>= Expand ("<cword>") <cr><cr>nnoremap <c-\>f:scs find F <c-r>=expand ("<cfile>") <cr><cr>nnoremap <c-\>i:scs Find I <c-r>=expand ("<cfile>") <CR><CR> Nnoremap <c-\>d:scs Find D <c-r>=expand ("<cword>") <CR><Cr> "-----youcompleteme-----Let g:ycm_server_python_interpreter= '/usr/bin/python2 ' let G:ycm_global_ycm_extra_ conf = ' ~/.ycm_extra_conf.py ' default profile let G:ycm_key_invoke_completion = ' <C-Tab> ' Cross file complete let G:ycm_confirm_ext ra_conf = 0 "Close load profile prompt let G:ycm_cache_omnifunc = 0" Turn off complement cache let G:ycm_enable_diag nostic_signs = 0 "Turn off diagnostic prompt Let g:ycm_enable_diagnostic_highlighting = 1" Turn off diagnostic highlighting "let G:ycm_show_diagnost ICS_UI = 0 "Turn off diagnostics uilet g:ycm_min_num_of_chars_for_completion = 3" n Character start auto complete "Get variable type Nnoremap <sile Nt><leader>yt:ycmcompleter gettype<cr> "Jump definition or declaration nnoremap &LT;SILENT&GT;&LT;LEADER&GT;YG: Ycmcompleter goto<cr> "Jump contains file Nnoremap <silent><leader>yi:ycmcompleter GoToInclude<CR>" Open Diagnostic information Nnoremap <silent><Leader>yd:YcmDiags<CR> "-----easygrep-----Let Easygrepmode = 2" Search by file type Should file let Easygreprecursive = 1 "recursive search let Easygrepcommand = 1"Use Greplet easygrepjumptomatch = 0 "Do not jump 

Appendix 2 Mycolor.vim

"Vim color file" Maintainer:hans fugal <[email protected]> "Last change: $Date: 2004/06/13 19:30:30 $" Last Cha Nge: $Date: 2004/06/13 19:30:30 $ "Url:http://hans.fugal.net/vim/colors/desert.vim" Version: $Id: Desert.vim,v 1.1 2004/ 06/13 19:30:30 vimboss Exp $ "Cool help Screens": He group-name ": he highlight-groups": he cterm-colorsset Background=dark If version > 580 "no guarantees for version 5.8 and below, but this makes it stop" complaining hi clear i F exists ("syntax_on") syntax reset Endifendiflet g:colors_name= "Desert" Hi normalguifg=white guibg=grey20 "Highlight Gro Upshi cursorguibg=khaki Guifg=slategrey "Hi cursorim" Hi Directory "Hi diffadd" Hi diffchange "Hi diffdelete" Hi difftext "Hi Errormsghi vertsplitguibg= #c2bfa5 guifg=grey50 gui=nonehi foldedguibg=grey30 Guifg=goldhi FoldColumnguibg=grey30 Guifg=tanhi incsearchguifg=slategrey Guibg=khaki "Hi Linenrhi modemsgguifg=goldenrodhi MoreMsgguifg=SeaGreenhi Nontextguifg=lightblue Guibg=grey30hi Questionguifg=sPringgreenhi Searchguibg=peru guifg=wheathi specialkeyguifg=yellowgreenhi statuslineguibg= #c2bfa5 guifg=black gui= Nonehi statuslinencguibg= #c2bfa5 guifg=grey50 gui=nonehi titleguifg=indianredhi visualgui=none Guifg=khaki guibg= Olivedrab "Hi visualnoshi warningmsgguifg=salmon" Hi wildmenu "Hi menu" Hi Scrollbar "Hi Tooltip" syntax highlighting Groupshi Commentguifg=skybluehi constantguifg= #ffa0a0hi identifierguifg=palegreenhi Statementguifg=khakihi Preprocguifg=indianredhi typeguifg=darkkhakihi specialguifg=navajowhite "Hi underlinedhi Ignoreguifg=grey40" hi Errorhi todoguifg=orangered guibg=yellow2 "Color terminal Definitionshi specialkeyctermfg=darkgreenhi NonTextcterm= Bold Ctermfg=darkbluehi directoryctermfg=darkcyanhi errormsgcterm=bold ctermfg=7 ctermbg=1hi IncSearchcterm=NONE Ctermfg=yellow ctermbg=greenhi searchcterm=none Ctermfg=grey Ctermbg=bluehi moremsgctermfg=darkgreenhi ModeMsgcterm= NONE ctermfg=brownhi Linenrctermfg=3hi questionctermfg=greenhi Statuslinecterm=bold,reversehi StatuSlinenc Cterm=reversehi Vertsplitcterm=reversehi titlectermfg=5hi Visualcterm=reversehi VisualNOScterm=bold, Underlinehi warningmsgctermfg=1hi wildmenuctermfg=0 Ctermbg=3hi Foldedctermfg=darkgrey Ctermbg=NONEhi Foldcolumnctermfg=darkgrey Ctermbg=nonehi Diffaddctermbg=4hi Diffchangectermbg=5hi DiffDeletecterm=bold ctermfg=4 Ctermbg=6hi difftextcterm=bold Ctermbg=1hi commentctermfg=darkcyanhi constantctermfg=brownhi Specialctermfg=5hi Identifierctermfg=6hi statementctermfg=3hi Preprocctermfg=5hi Typectermfg=2hi underlinedcterm=underline Ctermfg=5hi Ignorecterm=bold ctermfg=7hi ignorectermfg=darkgreyhi errorcterm=bold ctermfg=7 ctermbg=1 "vim:sw=4


Appendix 3 C.vim

"Not Wrapset nowrapif filereadable (" Tags.vim ") so tags.vimendifhi cfunction guifg=lightgreenhi cMacro guifg=    Lightredhi cglobal   Guifg=lightbluehi cmember   guifg=lightmagentahi def link ctypedef CType

Appendix 4 hitags.sh

#!/bin/bashctags-r--fields=+l; awk-f ' "' $ $ ~/^\tf/    {print $ \ n '} ' tags |  awk ' $ ~/^[a-za-z]/{print ' syn keyword cfunction ' $ ' 1>  tags.vim; awk-f ' ' ' $ $ ~/^\t[de]/{print ' \ n '} ' tags | awk ' $ ~/^[a-za-z]/{print ' syn keyword cmacro ' $ '    1>> tags.vim; awk-f ' ' ' $ $ ~/^\tt/    {print ' \ n ' } ' tags | awk ' $ ~/^[a-za-z]/{print ' syn keyword ctypedef ' $ '  1>> tags.vim; awk-f ' ' ' $ $ ~/^\tv/    {print $ ' \ N "} ' tags | awk ' $ ~/^[a-za-z]/{print ' syn keyword Cglobal ' $ '   1>> Tags.vim;


Appendix 5. ycm_extra_conf.py

Import osflags = ['-X ', ' C ', '-wall ', '-dos=linux ', '-i./mycode/igmpsnoop/h ', '-i./mycode/mldsnoop/h ', '-i./mycode/head_files ', '-i./mycode/g8132/inc ', '-i./mycode/nqa/inc ', '-i./mycode/mplste/inc ', '-I./mycode /mplsoam/inc ', '-i./mycode/cli ', '-i./mycode/trill/inc ', '-i./mycode/igmpsnoop_onu/inc ', '-i./mycode/hqos/inc ' , '-i./mycode/qos/inc ', '-i./mycode/mplsqos/inc ', '-i./mycode/pim/inc ', '-i./usp_device/osal/h ', '-I./USP_H eadfile/protocol/acl/h ', '-i./usp_headfile/protocol/hwroute/h ', '-i./usp_headfile/protocol/uspif/inc ', '-I/home/t Aopeng/workspace/vmware/linux_share/osal_linux/inc ', '-i/home/taopeng/workspace/vmware/linux_share/usp_ Linux3.12.17/inc ']def makefinalflag (): Workdir = Os.path.dirname (Os.path.abspath (__file__)) finalflags = [] for flag I n flags:if flag.startswith ('-i '): Path = Flag[len ('-i '):] flag = '-I ' + os.path.join (workdir, path) F Inalflags.append (flag) return FinalflagS def flagsforfile (FileName, **kwargs): return {' Flags ': Makefinalflag (), ' Do_cache ': True}if __name__ = = ' __m Ain__ ': Print (Flagsforfile ("Test"))


Using VIM to build the IDE (for C language)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.