Convert VIM to IDE in Ubuntu

Source: Internet
Author: User

In Ubuntu, convert VIM to IDE. First, we install the vim editor. You can choose sudo apt-get install vim-gtk to install the plug-in ctags, this plug-in is mainly used to generate an index file from the ctags program. The ctags program is called "Exuberant Ctags" and is a substitute for the ctags program on Unix, and more powerful than it, is the default ctags program in most Linux releases. so what is the tags file used? What if you read a function call, a variable, a macro, and so on while reading the program and want to know where they are defined? Use grep? It will find many irrelevant places. <C-]> who knows how to use it? When the cursor is on a function or variable, press "Ctrl +]". the cursor will automatically jump to its definition. It's amazing. You don't have to envy Visual Studio programmers any more. Start to envy me ~ _~. On this site: http://ctags.sourceforge.net, download a file like a ctags-5.8.tar.gz down: unzip the installation with the following command: $ tar-xzvf ctags-5.8.tar.gz $ cd ctags-5.8 $. /configure $ make $ sudo make install installation is complete. Then you can start to use ctags by remembering the following seven commands: (very simple, huh, huh) 1. $ ctags-R * ($ is a Linux Shell prompt) 2. $ vi-t tag (replace the tag with the variable or function name you want to search for) 3.: ts (the command starting with ":" In tags list is the command line mode command in VI) 4.: tp (tp help Note: tags preview) --- skip this command is not commonly used, you do not need to remember 5.: tn (tn mnemonic: tags next) --- skip this command is not commonly used, you do not need to remember 6. ctrl +] 7. ctrl + T for the first entry, open the terminal in the Code directory, or use cd to switch to the terminal, and then enter $ ctags-R, we can see that a tags file is generated at this time. Then we use the second command, for example, Input $ vim-t main, which indicates that we use vim to open the main function in this directory, next we should be able to see the main letter on the terminal If you want to find a function or variable definition, you can directly move the cursor to this place and then press Ctrl +]. in this way, you can directly jump to the source file defined by this variable or function, and position the cursor to this line. You can use "Ctrl + t" to return the original location. Even if you use "Ctrl +]" for N times to find N variables, you can press "Ctrl + t" for N times to return to the originally opened file, which will be returned in the original way. Pai_^ next let's take a look at how to manually set vim under ubuntu. Next we will introduce a common method. First, we can create. vimrc file, which is hidden by default, so we need to use the Chrl + H combination key to display it, and then set some vim configuration usage in it, if you are the same as me, it is only convenient for vim to read the code, then I suggest you set some basic functions: Use gedit. open vimrc and enter: set syntax = on "color scheme colorscheme torte" Remove input error prompt sound set noeb "when processing unsaved or read-only files, pop-up confirmation set confirm "automatic indent set autoindentset cindent" automatic newline set wrap "entire line feed set linebreak" Tab key width set tabstop = 4 "unified indent to 4 set softtabstop = 4 set shiftwidth = 4 "Don't use Place spaces in place of the tab set noexpandtab "Use the tab set smarttab at the beginning of the row and segment" display the row number set number "number of historical records set history = 1000" prohibit generation of temporary files set nobackupset noswapfile "Search ignore case sensitivity set ignorecase "search by character highlighted set hlsearchset incsearch" replace set gdefault "encoding settings set enc = utf-8set fencs = UTF-8, set helplang = cnset encoding = utf8 set langmenu = zh_CN.UTF-8 set imcmdline source $ VIMRUNTIME/delmenu. vim source $ VIMRUNTIME/men U. vim "sets the font. Set guifont = Liberation \ Mono \ 12 "set guifont = Fixedsys \ Excelsior \ 3.01 \ 14 let Tlist_Show_One_File = 1" the tags of multiple files are not displayed at the same time, only show the current file's let Tlist_Exit_OnlyWindow = 1 "if the taglist window is the last window, exit vim let Tlist_Use_Right_Window = 1 ". The taglist window let Tlist_Auto_open = 1 is displayed in the right window. If you want to open the taglist window and save it after VIM is started. The next step is to install the taglist plug-in. Note that the taglist depends on the ctags, so you must install the ctags first. Otherwise, the taglist cannot be installed! To http://vim.sourceforge.net/scripts/download_script.php? Src_id = 6416 find the installation package of taglist and decompress the package. You can right-click the address and find a command option. decompress the package and click here, instead of using the command # unzip-d taglist taglist_42.zip # cd taglist to decompress the package. Run the following command: cp doc/taglist.txt/usr/share/vim/vim73/doc/cp plugin/taglist. vim/usr/share/vim/vim73/plugin/different versions of vim are different, so you may be using another version of vim **, not necessarily 73. In this way, jason @ ubuntu :~ /Lidar/3530/working-copy $ vim 3dMapping_thread.cpp open the source file and enter TlistOpen to display the tag column on the right. The window on the right is the TagList window described above, which lists main. the tags in the c file are classified according to "typedef", "variable", and "function. move the cursor over VimMain, the red box on the left, press enter, the source program will automatically jump to the definition of VimMain, the red box on the right. this is the most basic and commonly used TagList operation. I will teach you a common operation. If you do not want to redirect the source code when browsing the TagList window, but want to see the complete expression of the tag in the source code, you can move the cursor to the tag you want to see, and then press the Space key, in the command bar below, the yellow box below, the complete syntax of the tag in the source code is displayed, rather than jump to the source code. input: Q introduces taglist. Input: TlistOpen switches between source code and tag. Next install the WinManage plug-in to display the directory to the http://www.vim.org/scripts/script.php? Script_id = 95 download the plug-in, decompress it, And then; sudo cp winmanager.txt/usr/share/vim/vim73/doc/sudo cp winfileexplorer. vim/usr/share/vim/vim73/plugin/sudo cp winmanager. vim/usr/share/vim/vim73/plugin/sudo cp wintagexplorer. vim/usr/share/vim/vim73/plugin. in vimrc, enter let g: winManagerWindowLayout = 'fileexplorer | taglist' nmap wm: WMToggle <cr>. Next try the effect: jason @ ubuntu :~ $ Vim 3dMapping_thread.cpp and press wm in normal mode. Two windows, directories, and taglist are displayed on the left. After pressing wm, it disappears. Every time you press the entel key to open the corresponding function or directory.: Switch between TlistOpen and: q.

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.