Linux VIM compiler modification

Source: Internet
Author: User
Tags define function set background

Modifying the VIM Compiler

Create the. vimrc file under the root directory and copy and save the code below.
Create a. vimrc file in the root directory so that you can write code as an administrator
Note: (This vim text compiler needs to install the Python and g++ compilers in the Linux environment first)
My VIM configuration mainly has the following advantages:
1. Press F5 to directly compile and execute C, C + +, Python, Java code and execute shell script, press "F8" to debug C, C + + code
2. Automatically insert header, new C, C + +, Python, Java, Shell source files automatically inserted header: including the file name, author, contact, establishment time, etc., the reader can change their own according to the requirements
3. Map "Ctrl + A" To select All and copy shortcut keys for easy copying of code
4. Press "F2" to directly eliminate blank lines in the code
5. "F3" can list the current directory file, open the tree-like file directory
6. Support mouse selection, direction key movement
7. Code highlighting, auto indent, display line number, display status line
8. Press "Ctrl + P" to complete the auto-completion
9.[], {}, (), "", "" and so on are automatically complete
10. Other features readers can study the following documents

Code
Map <f9> :call saveinputdata () <cr>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 " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "  Show Related   " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" set shortmess=ati    "" " When it starts, it doesn't show the tips for helping Ugandan children    "winpos 5 5              Set window position    SET&NBsp;lines=40 columns=155     "  Set window size   set go=                 Do not graph buttons    color asmanian2         Set Background theme    set guifont=courier_new:h10:cansi     "  Set font   " syntax on              Syntax highlighting   autocmd InsertLeave * se nocul     highlighting the current line with light    autocmd InsertEnter * se cul       Highlight current line with light    set  ruler              Show Rulers   set  showcmd          "  Input command display, see clearly some   " set  cmdheight=1      the height of the   command line (under the status line), set to 1   "Set whichwrap+=<,>,h ,l    "  Allow BACKspace and cursor keys across line boundaries (not recommended)    "set scrolloff=3     "   Keep 3 lines away when the cursor moves to the top and bottom of buffer   set novisualbell     "  do not blink (do not understand)    set statusline=%f%m%r%h%w\ [format=%{&ff}]\ [type=%y]\ [pos=%l,%v][%p%%]\ %{ Strftime (\ "%d/%m/%y\ -\ %h:%m\")}    "status line display content   set laststatus=1        Start Display status line (1), always show status line (2)   set foldenable          Allow folding   set foldmethod=manual      manual Folding    set  background=dark  "Background using black  set nocompatible  " remove annoying about VI consistency mode, avoid some bugs and limitations of previous versions    "  Show 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," "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "  *.cpp,*. [ch],*.sh,*.java,*.py exec  ": Call settitle ()"   "" "Define function Settitle, automatically insert file header  func  Settitle ()       "If the file type is. sh file      if &filetype  ==  ' sh '          call setline (1, "\###################### ################################################### ")           Call append ("."),  "\# file name: ". Expand ("%"))           call append (Line (".") +1,  "\# author: delong qi")     &Nbsp;    call append (Line (".") +2,  "\# mail: [email protected] ")          call append (Line (". ") +3,  "\# created time: ". Strftime ("%c"))           call append (Line (".") +4,  "\#########################################################################")           call append (Line (".") +5,  "\#!/bin/bash")          call append (Line (".") +6,  "")      endif    if &filetype ==  ' Python '          call setline (1,  "#********************* ")           Call append ("."),    "# >file name: ". Expand ("%"))           call append (Line (".") +1,  "#&Nbsp;>author: delong qi ")          call append ( Line (".") +2,  "# >mail: [email protected] ")          call append (Line (". ") +3,  "#************************************************************************/")           call append (Line (".") +4,  "")         call append (Line (".") +5,  "#!/bin/usr/env python ")          call  Append (Line (".") +6,  "# -*-coding:utf-8 -*- ")          call  append (Line (".") +7,  "")      endif    if &filetype ==  ' CPP '         call setline (1,  "/********************************* ")          call  Append (Line ("."),  "    > File Name: ". Expand("%"))          call append (Line (".") +1,  "    > author: ma6174")           call append (Line (".") +1,  "    > author: delong qi")           call append (Line (".") +2,  "    > Mail: [email protected]   ")          call append (Line (". ") +4,  " ************************************************************************/")           call append (Line (".") +5,  "")         call append (Line (".") +6,  "#include <iostream>")         call append (Line (".") +7,  "using namespace std;")         call append (Line (".") +8,  "")     endif    if &filetype ==  ' C '          call setline (1,  "/**************************************** ")          call append (line ("."),  "    > File Name: ". Expand ("%"))          call append (Line (".") +1,  "    > author: delong qi")           call append (Line (".") +2,  "    > Mail: [email protected]   ")          call append (Line (". ") +3,  "    > Created Time: " strftime ("%c")           call append (Line (".") +4,  " ************************************************************************/")           call append (Line (".") +5,  "")         call append (Line (".") +6,  "#include <stdio.h>")         call append (Line (".") +7,  "")     endif    if &filetype ==  ' Java '         call setline (1,  "/********************************** ")          call  Append (Line ("."),  "    > file name:  ". Expand ("% "))          call append (Line (" .") +1,  "    > author: delong qi")           call append (Line (".") +2,  "    > Mail: [email protected]   ")          call append (Line (". ") +3,  "    > Created Time: " strftime ("%c")           call append (Line (".") +4,  " ************************************************************************/")           call append (Line (".") +5,  "")         call append (Line (".") +6, "public class ". Expand ("%"))         call append (line (".") +7, "")     endif     "automatically navigates to end of file after new file     autocmd  BufNewFile * normal Gendfunc  "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " nmap <leader>w :w!<cr>nmap <leader>f :find<cr>  "  Map Select All + Copy  ctrl+amap <C-A> ggVGYmap! <C-A> <Esc>ggVGYmap <F12>  gg=g "  Selected  Ctrl+c  copy 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>   lists the current directory file   map  <F3> :tabnew .<CR>   "Open the tree file directory   map <C-F3> \be    c,c++  Press F5 to compile run MAP&NBSP;&LT;F5&GT;&NBSP;:CALL&NBSP;COMPILERUNGCC () &LT;CR&GT;FUNC!&NBSP;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 '         :!. /%    elseif &filetype ==  ' python '          exec  "!python %"         exec  "!python  %< "    endifendfunc" c,c++ Debug Map <f8> :call rungdb () <CR>func!  rungdb ()     exec  "W"     exec  "!g++ % -g -o %<"     exec  "!gdb ./%<" endfunc  "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "   Set automatically load Set autoread when the file is changed  quickfix mode autocmd filetype c,cpp map < Buffer> <leader><space> :w<cr>:make<cr> "Code completion  set completeopt= preview,menu  "Allow plugin   filetype plugin on" to share the Clipboard   set clipboard+=unnamed   "Never backup   set nobackup" make  run: set makeprg=g++\ -wall\ \ % "Automatically save set  autowriteset ruler                       Open the status bar ruler set cursorline                "  Highlight current line set magic                     "  Set Magic set guioptions-=t               Hide the toolbar set guioptions-=m             "  Hide menu bar" set statusline=\ %<%f[%1*%m%*%n%r%h]%=\  %y\ %0 (%{&fileformat}\ %{&encoding}\ %c:%l/%l%) \ "  Sets the information displayed in the status line set  foldcolumn=0set foldmethod=indent set foldlevel=3 set foldenable                  Start folding   Do not use VI's keyboard mode, but Vim's own set  nocompatible "  Syntax highlighting set syntax=on"   get rid of input error sounds Set noeb "  when working with unsaved or read-only files, pop up the confirm set  confirm "  Auto indent set autoindentset cindent"  tab key width set tabstop=4 "  Unified indent to 4set  softtabstop=4set shiftwidth=4  Do not use spaces instead of tabs set noexpandtab   tabs at the beginning of lines and segments Set smarttab   Show line numbers set number   History number set history=1000 "Prohibit generate temporary file Set nobackupset noswapfile" Search ignores case set ignorecase "search verbatim 符高亮 Set  hlsearchset incsearch "Inline replace Set gdefault" encoding setting Set enc=utf-8set fencs=utf-8,ucs-bom, shift-jis,gb18030,gbk,gb2312,cp936 "Language Settings set langmenu=zh_cn. UTF-8SET&NBSP;HELPLANG=CN "  My status line display content (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 the height of the status line set laststatus=2   command line (under the status line), The default is 1, here is 2set cmdheight=2 "  detect file type Filetype on"   load file type plug-in Filetype plugin on "  Load related indentation files for a specific file type Filetype indent on "  Save global variable set viminfo+=!"   Words with the following symbols do not wrap set iskeyword+=_,$,@,%,#,-"  Putting number of pixel rows inserted set linespace=0"   Command line auto-completion in enhanced modeOperation Set wildmenu "  make the backspace (indent, eol, start) normal processing set backspace=2"   Allow backspace and cursor keys to span line boundaries set whichwrap+=<,>,h,l   can use the mouse anywhere in buffer (similar to double-clicking the mouse in the workspace in office) set  Mouse=aset selection=exclusiveset selectmode=mouse,key "  by using:  commands command, tell us which line of the file has been changed set  report=0 "  white space between divided windows, easy to read set fillchars=vert:\ ,stl:\ ,stlnc:\"   highlight matching parentheses set  showmatch "  matches the time of the brace highlighting (in very one second) set matchtime=1"   Keep 3 lines away when the cursor moves to the top and bottom of buffer set scrolloff =3 "  provides auto indent set smartindent for C programs"   Highlight ordinary txt files (requires Txt.vim script) au bufread,bufnewfile *   setfiletype txt "Auto-complete: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>ifunction! closepair (char)     if  Getline ('. ') [Col ('. ')  - 1] == a:char        return  "\<right> "    else        return a:char     endifendfunctionfiletype plugin indent on  "Open File type detection,  added this to use the smart complement set  completeopt=longest,menu "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ",", "", "", "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""   "Nerdtee set let nerdchristmastree=1let nerdtreeautocenter=1let  nerdtreebookmarksfile= $VIM. ' \data\nerdbookmarks.txt ' Let nerdtreemousemode=2let nerdtreeshowbookmarks=1let nerdtreeshowfiles =1let nerdtreeshowhidden=1let nerdtreeshowlinenumbers=1let nerdtreewinpos= ' left ' let  Nerdtreewinsize=31nnoremap f :nerdtreetogglemap <f7> :nerdtree<cr>  

Linux vim compiler modification

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.