Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure VIM as C++ development editor in Ubuntu

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to configure VIM as a C++ development editor in Ubuntu. The article is very detailed and has certain reference value. Interested friends must finish reading it!

1. Copy the configuration file to the user environment, create a new .vim folder, and create a bundle subfolder.

Sudo cp / etc/vim/vimrc / home/wangy/.vimrc

Sudo mkdir / home/wangy/.vim

Sudo mkdir / home/wangy/.vim/bundle

Sudo mkdir / home/wangy/.vim/bundle/vundle

The configuration file for bundle is as follows:

"the new configuration is put here in set nocompatible" be iMprovedfiletype off "bundle 'gmarik/vundle'' My Bundles here:" original repos on githubBundle 'tpope/vim-fugitive'Bundle' Lokaltog/vim-easymotion'Bundle 'rstacruz/sparkup'. {'rtp':' vim/'} Bundle 'tpope/vim-rails.git' "vim-scripts reposBundle' L9'Bundle 'FuzzyFinder'" non github repos "Bundle' git://git.wincent.com/command-t.git'" Bundle 'https://github.com/scrooloose/nerdtree.git'"... filetype plugin indent on "required!" Brief help-here are vundle commands ": BundleList-list configured bundles": BundleInstall (!)-install (update) bundles ": BundleSearch (!) foo-search (or refresh cache first) for foo": BundleClean (!)-confirm (or auto-approve) removal of unused bundles "" see: h vundle for more details or wiki for FAQ "NOTE: comments after Bundle command are not allowed..

2. Install NERDTree

Bundle 'https://github.com/scrooloose/nerdtree.git'

The usage is as follows:

Nmap: NERDTree shortcut key

: NERDTree is enabled

Ctrl+w can switch between left and right windows.

P to the upper directory, P to the root directory

O Open the file or directory, Q exit the plug-in

3. Install tagbar

Install ctags,sudo apt-get install ctags first

Bundle 'https://github.com/majutsushi/tagbar.git'

The configuration file is as follows:

"tagbar Settings -" Shortcut key nmap: TagbarTogglelet g:tagbar_width = 20 "tagbar's width, default 20" let g:tagbar_left = 1 "on the left sidelet g:tagbar_right = 1" on the right sidelet NERDTreeIgnore= ['\ .pyc','\ .pyo','\ .swp','\ ~'] "ignore * .py [co], * .pypy * ~

Use mode F4 shortcut key, exit is Q

4. Other plug-ins

Bundle 'https://github.com/scrooloose/nerdtree.git'

Bundle 'https://github.com/majutsushi/tagbar.git'

Bundle 'https://github.com/terryma/vim-multiple-cursors.git'

Bundle 'https://github.com/upsuper/vim-colorschemes.git'

Bundle 'https://github.com/vim-scripts/cppcomplete.git'

My vim configuration mainly has the following advantages:

1. Press F5 to compile and execute C, C++, java code and shell script directly, and press "F8" to debug C, C++ code.

two。 Insert the file header automatically, and insert the header automatically when you create a new C or C++ source file: including the file name, author, contact information, establishment time, etc. Readers can change them according to their needs.

3. Map "Ctrl + A" to select all and copy shortcuts, making it easy to copy code

4. Press "F2" to directly eliminate the blank lines in the code.

5. "F3" lists the current directory files and opens the tree file directory

6. Support mouse selection and movement of arrow keys

7. Code highlight, automatically indent, display line number, display status line

8. Press "Ctrl + P" to complete automatically.

9. [], {}, (), "",'', etc.

10. Readers of other functions can study the following files

Map: call SaveInputData () func! SaveInputData () exec "tabnew" exec 'normal "+ gP' exec" w! / tmp/input_data "endfunc" colorscheme torte "colorscheme murphy" colorscheme desert "colorscheme desert" colorscheme elflordcolorscheme ron "set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936" set termencoding=utf-8 "set encoding=utf-8" set fileencodings=ucs-bom,utf-8 Cp936 "set fileencoding=utf-8" display related " When "set shortmess=atI" starts, the prompt to assist Ugandan children is not displayed. "winpos 55" sets the window location "set lines=40 columns=155" setting. Set window size set go= "No graphics button" color asmanian2 "set background theme" set guifont=Courier_New:h20:cANSI "set font" syntax on "syntax highlight autocmd InsertLeave * se nocul" highlight current line autocmd InsertEnter * se cul "highlight current line" set ruler "display ruler set showcmd" input command See more clearly the height of the "set cmdheight=1" command line (under the status line) Set to 1 "set whichwrap+=,h,l" to allow backspace and cursor keys to cross line boundaries (not recommended) keep 3 lines away from set novisualbell when the "set scrolloff=3" cursor moves to the top and bottom of the buffer "do not flash (do not understand) set statusline=%F%m%r%h%w\ [FORMAT=% {& ff}]\ [TYPE=%Y]\ [POS=%l" % v] [% p%%]\% {strftime (\ "% d/%m/%y\ -\% HGV% M\")} "content displayed on the status line set laststatus=1" start display status line (1), always display status line (2) set foldenable "allow folding set foldmethod=manual" manually collapse "set background=dark" background use black set nocompatible "remove annoying vi consistency mode Avoid some bug and limitations of previous versions "display Chinese help if version > = 603 set helplang=cn set encoding=utf-8endif" set color scheme "colorscheme murphy" font "if (has (" gui_running "))" set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 "endif" "" New file title "" "" New .c .h, .sh, .java files Automatically insert the file header autocmd BufNewFile * .cpp,*. [ch], * .sh,*.java exec ": call SetTitle ()" defines the function SetTitle Automatically insert the file header func SetTitle () "if the file type is .sh file if & filetype = = 'sh' call setline (1,"\ # ") call append (line (". ") "\ # File Name:" .ma6174@163.com ("%") call append (line (".") + 1, "\ # Author: ma6174") call append (line (".") + 2, "\ # mail: ma6174@163.com") call append (line (".") + 3, "\ # Created Time:" .strftime ("% c") call append (line (".") + 4 "\ # #") call append (line (".") + 5, "\ #! / bin/bash") call append (line (".") + 6, ") else call setline (1 "/ *") call append (line ("."), "> File Name:". Call append ("%") call append (line (".") + 1 "> Author: ma6174") call append (line (".") + 2, "> Mail: ma6174@163.com") call append (line (".") + 3, "> Created Time:" .strftime ("% c") call append (line (".") + 4 "* /") call append (line (".") + 5, ") endif if & filetype = = 'cpp' call append (line (". ") + 6," # include ") call append (line (". ") + 7 "using namespace std ") call append (line (". ") + 8,") endif if & filetype = ='c 'call append (line (".") + 6, "# include") call append (line (".") + 7, ") endif" if & filetype = =' java' "call append (line (". ") + 6," public class ".percent ("% "))" call append (line (".") + 7, ")" endif "after creating a new file Automatically navigate to the end of the file autocmd BufNewFile * normal Gendfunc "keyboard life" Make the "nmap w: wrecknmap f: find" mapping all selected + copy ctrl+amap ggVGYmap! GgVGYmap gg=G "Ctrl+c copy vmap" + y "goes to the blank line nnoremap: G / ^\ s copy tabnew d" comparison file nnoremap: vert diffsplit "New tag map: tabnew" lists the current directory file map: tabnew. "Open the tree file directory map\ be". Press F5 to compile and run map: call CompileRunGcc () func! CompileRunGcc () exec "w" if & filetype = ='c 'exec "! Gmail +%-o%

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report