~
Pull long time, eventually make almost the same, and sure enough the program ape still need a little toss spirit ah.
First you want to install VIM, command: sudo apt-get install vim
Vim It's just an editor, it's not an IDE (for example, Codeblocks). The IDE is equivalent to having a house loaded with all sorts of things you just have to use. Vim but to own a variety of things, the equivalent to buy a blank room, oneself to decorate the house.
How to install the g++ compiler can take a look at my last blog post.
Simple C + + configuration for 1:vim (syntax highlighting. Indent: )
In the home folder, under the new. vimrc file, the. File is not visible, press CTRL + H to display
Then configure the. VIMRC, and the following is my configuration
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Show related
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"set shortmess = atI" Don't show the prompt for Uganda children when it starts
"winpos 5 5" set window position
"set lines = 40 columns = 155" set form size
"set nu" display line number
set go = "don't graphical button
"color asmanian2" set background theme
set guifont = Courier_New: h10: cANSI "Set font
"syntax on" syntax highlighting
"set ruler" show ruler
The command set showcmd "is displayed, you can see it clearly.
"set cmdheight = 1" The height of the command line (under the status line), set to 1
"set whichwrap + = <,>, h, l" agree that backspace and cursor keys cross line boundaries (not recommended)
"set scrolloff = 3" keep 3 lines when the cursor moves to the top and bottom of the buffer
set novisualbell "don't blink
set statusline =% F% m% r% h% w \ [FORMAT =% {& ff}] \ [TYPE =% Y] \ [POS =% l,% v] [% p %%] \% {strftime ( \ "% d /% m /% y \-\% H:% M \")} "What the status line shows
set laststatus = 1 "Start showing the status line (1), always show the status line (2)
"set foldenable"
set foldmethod = manual "manual folding
"set background = dark" background uses black
"set nocompatible" removes the annoying vi consistency mode and avoids some bugs and limitations of previous version numbers
"Show Chinese Help
if version> = 603
set helplang = cn
set encoding = utf-8
endif
"Set color scheme
"colorscheme murphy
"Font
"if (has (" gui_running "))
"set guifont = Bitstream \ Vera \ Sans \ Mono \ 10
"endif
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
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"" "" "New file title" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
"New .c, .h, .sh, .java files. Insert the file headers yourself.
autocmd BufNewFile * .cpp, *. [ch], *. sh, *. java exec ": call SetTitle ()"
"" Define the function SetTitle, and actively insert the file header yourself
func SetTitle ()
"Assuming the file type is .sh file
if & filetype == ‘cpp’
call setline (1, "# include <iostream>")
call append (line ("."), "#include <cstdio>")
call append (line (".") + 1, "#include <algorithm>")
call append (line (".") + 2, "#include <string>")
call append (line (".") + 3, "")
call append (line (".") + 4, "using namespace std;")
call append (line (".") + 5, "int main ()")
call append (line (".") + 6, "{")
call append (line (".") + 7, "")
call append (line (".") + 8, "")
call append (line (".") + 8, "return 0;")
call append (line (".") + 9, "}")
endif
if & filetype == ‘c’
call append (line (".") + 6, "#include <stdio.h>")
call append (line (".") + 7, "")
endif
"After creating a new file. Actively position yourself at the end of the file
autocmd BufNewFile * normal G
endfunc
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
"Keyboard commands
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
nmap <leader> w: w! <cr>
nmap <leader> f: find <cr>
"Map Select All + Copy ctrl + a
map <C-A> ggVGY
map! <C-A> <Esc> ggVGY
map <F12> gg = G
"Copy with Ctrl + c selected
vmap <C-c> "+ y
"Go blank line
nnoremap <F2>: g / ^ \ s * $ / d <CR>
"Compare files
nnoremap <C-F2>: vert diffsplit
"New label
map <M-F2>: tabnew <CR>
"List current folder files
map <F3>: tabnew. <CR>
"Open Tree File Folder
map <C-F3> \ be
"C. C ++ compile and execute as F5
map <F5>: call CompileRunGcc () <CR>
func! CompileRunGcc ()
exec "w"
if & filetype == ‘c’
exec "! g ++% -o% <"
exec "! ./% <"
elseif & filetype == ‘cpp’
exec "! g ++% -o% <"
exec "! ./% <"
elseif & filetype == ‘java’
exec "! javac%"
exec "! java% <"
elseif & filetype == ‘sh’
:! ./%
endif
endfunc
"C, C ++ debugging
map <F8>: call Rungdb () <CR>
func! Rungdb ()
exec "w"
exec "! g ++% -g -o% <"
exec "! gdb ./% <"
endfunc
“" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" “" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
"" Useful settings
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Set to load automatically when the file is modified
set autoread
"quickfix mode
autocmd FileType c, cpp map <buffer> <leader> <space>: w <cr>: make <cr>
"Code completion
set completeopt = preview, menu
"Agree plugin
filetype plugin on
"Share Clipboard
set clipboard + = unnamed
"Never back up
set nobackup
"make execute
: set makeprg = g ++ \ -Wall \ \%
"Save yourself
set autowrite
set ruler "Turn on the status bar ruler
set magic "set magic
set guioptions- = T "hide toolbar
set guioptions- = m "hide menu bar
"set statusline = \% <% F [% 1 *% M% *% n% R% H]% = \% y \% 0 (% {& fileformat} \% {& encoding} \% c:% l /% L%)
"Set the information displayed in the status line
set foldcolumn = 0
set foldmethod = indent
set foldlevel = 3
set foldenable "start folding
"Don't use vi's keyboard mode, but vim's own
set nocompatible
"Syntax highlighting
set syntax = on
"Remove the wrong input sound
set noeb
"When processing unsaved or just reading files, popup confirmation
set confirm
"Indent yourself
set autoindent
set cindent
"Tab width
set tabstop = 4
"Uniform indentation is 4
set softtabstop = 4
set shiftwidth = 4
"Don't replace tabs with spaces
set noexpandtab
"Use tabs at the beginning of lines and paragraphs
set smarttab
"Show line number
set number
"History
set history = 1000
"Prohibit temporary files
set nobackup
set noswapfile
"Search ignore uppercase and lowercase
set ignorecase
"Search character-by-character highlighting
set hlsearch
set incsearch "Inline replacement
set gdefault
"Encoding settings
set enc = utf-8
set fencs = utf-8, ucs-bom, shift-jis, gb18030, gbk, gb2312, cp936
"language settings
set langmenu = zh_CN.UTF-8
set helplang = cn
"What my status line shows (including file type and decoding)
"set statusline =% F% m% r% h% w \ [FORMAT =% {& ff}] \ [TYPE =% Y] \ [POS =% l,% v] [% p %%] \% {strftime (\ "% d /% m /% y \-\% H:% M \")}
"set statusline = [% F]% y% r% m% *% = [Line:% l /% L, Column:% c] [% p %%]
"Always show status line
set laststatus = 2
"The height of the command line (under the status line), I think 1, this is 2
set cmdheight = 2
"Detecting File Types
filetype on
"Load file type plugin
filetype plugin on
"Load related indent files for specific file types
filetype indent on
"Save Global Variable
set viminfo + =!
"Don't cut lines with words such as
set iskeyword + = _, $, @,%, #,-
"Number of pixel lines inserted between characters
set linespace = 0
"Command line in enhanced mode finishes itself
set wildmenu
"Make backspace handle indent, eol, start, etc. normally
set backspace = 2
"Agree backspace and cursor keys across line boundaries
set whichwrap + = <,>, h, l
"Able to use the mouse anywhere in the buffer (similar to double-clicking the mouse in the workspace to locate the office)
set mouse = a
set selection = exclusive
set selectmode = mouse, key
"Tell us which line of the file was changed by using: commands
set report = 0
"Show blanks between cut forms for easy reading
set fillchars = vert: \, stl: \, stlnc:
"Highlight matching brackets
set showmatch
"Match parenthesis highlighting time (in tenths of a second)
set matchtime = 1
"The cursor moves to the top and bottom of the buffer with a distance of 3 lines
set scrolloff = 3
"Provide your own indentation for C programs
set smartindent
"Highlight normal txt file (requires txt.vim script)
au BufRead, BufNewFile * setfiletype txt
"Self-completion
: inoremap (() <ESC> i
: inoremap) <c-r> = ClosePair (‘)‘) <CR>
: inoremap {{<CR>} <ESC> O
: inoremap} <c-r> = ClosePair (‘}‘) <CR>
: inoremap [[] <ESC> i
: inoremap] <c-r> = ClosePair (‘]‘) <CR>
: inoremap "" "<ESC> i
: inoremap ‘‘ ‘<ESC> i
function! ClosePair (char)
if getline (‘.‘) [col (‘.‘)-1] == a: char
return "\ <Right>"
else
return a: char
endif
endfunction
filetype plugin indent on
"Open file type detection, this sentence is enough to use intelligent completion
set completeopt = longest, menu
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"CTags settings
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
let Tlist_Sort_Type = "name" "Sort by name
let Tlist_Use_Right_Window = 1 "Show form on right
let Tlist_Compart_Format = 1 "compression method
let Tlist_Exist_OnlyWindow = 1 "Assuming there is only one buffer, the kill window also kills the buffer
let Tlist_File_Fold_Auto_Close = 0 "Don't close tags of other files
let Tlist_Enable_Fold_Column = 0 "Don't show collapsed tree
autocmd FileType java set tags + = D: \ tools \ java \ tags
"autocmd FileType h, cpp, cc, c set tags + = D: \ tools \ cpp \ tags
"let Tlist_Show_One_File = 1" Show tags for multiple files at a time. Show only the current file
"Setting tags
set tags = tags
"set autochdir
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Other Dongdong
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" ""
"Open Taglist by default
let Tlist_Auto_Open = 1
"" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
"Tag list (ctags)
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
let Tlist_Ctags_Cmd = ‘/ usr / bin / ctags’
let Tlist_Show_One_File = 1 "Show tags of multiple files at a time, only the current file
let Tlist_Exit_OnlyWindow = 1 "Assuming the taglist form is the last form, exit vim
let Tlist_Use_Right_Window = 1 "Show the taglist form in the right form
"General settings for minibufexpl plugin
let g: miniBufExplMapWindowNavVim = 1
let g: miniBufExplMapWindowNavArrows = 1
let g: miniBufExplMapCTabSwitchBufs = 1
let g: miniBufExplModSelTarget = 1
"+ = Be sure not to have spaces after it, otherwise you won't find it
set tags + = ~ / .vim / stl / tags
Complete artifact Omnicppcomplete,vim, C + + code completion plug-in, based on the ctags generated tag library.
2: Installation
Official version download: (http://www.vim.org/scripts/download_script.php?
src_id=7722)
Extract the compressed package (including After/autoload/doc three folders) to the ~/.vim path
I do not have a. Vim folder, you create your own in the home folder
Download the STL source code. Address: (http://www.vim.org/scripts/script.php?)
script_id=2358) unzip to the inside of the. Vim folder you just created
Ok. Now that the tools are ready, the next step is to create tags.
Go to the STL folder that you just downloaded. Use the Ctags command to generate the tags file, such as the following commands:
ctags -R –c++-kinds=+p –fields=+iaS –extra=+q .
A tags file appears under the STL Source code folder
Add the path to the tags file in the ~/.vimrc file, my STL source code folder is/home/sphinx/software/stl, so it's in. VIMRC Riga.
set tags+=/sphinx/Software/stl/tags
And then open Vim is this effect ~
Effects such as the following: (using CTRL + N or ctrl+p complement)
I also configured vim for the first time. It took a long time, or that sentence: Do not always want to rely on others, to strive to become the dependence of others. So do not directly let people directly to you to configure, to own a little Google. Baidu, a little groping. Can let others help a small piece, but can not all let others help, such ability to improve self-study capacity. Come on! Today, Linux is tossing here, review the probability theory to go slightly ~ ~ ~
Linux Novice How to configure Vim as a C + + programming environment (can be STL self-completion)