跳到正文

个人记录

vim配置

「QQ红包」约 13 分钟
原文
文章信息与版本

文章信息

发布
2018年5月15日
收录
2026年7月9日
更新
2026年11月21日
篇幅
约 13 分钟
获赞
7

版本

  1. v1当前
C++
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

set nocompatible
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below.  If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
  endif

  " If using a dark background within the editing area and syntax highlighting
  " turn on this option as well
  "set background=dark

  " Uncomment the following to have Vim jump to the last position when
  " reopening a file
  "if has("autocmd")
  "  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  "endif

  " Uncomment the following to have Vim load indentation rules and plugins
  " according to the detected filetype.
  "if has("autocmd")
  "  filetype plugin indent on
  "endif

  " The following are commented out as they cause vim to behave a lot
  " differently from regular Vi. They are highly recommended though.
  set showcmd       " Show (partial) command in status line.
  set showmatch     " Show matching brackets.
  set ignorecase        " Do case insensitive matching
  set smartcase     " Do smart case matching
  set incsearch     " Incremental search
  set autowrite     " Automatically save before commands like :next and :make
  set hidden        " Hide buffers when they are abandoned
  set mouse=a       " Enable mouse usage (all modes)
  set clipboard=unnamedplus
  " Source a global configuration file if available
  if filereadable("/etc/vim/vimrc.local")
    source /etc/vim/vimrc.local
    endif
    set nu    
    set tabstop=4
    set cursorline   
    set cursorcolumn       
    set autoread     
    set nobackup
    set ruler
    syntax on
    set shortmess=atI
    set showcmd
    :set shiftwidth=4
    set autoindent
    set cindent
    set smartindent
    set noswapfile
    set langmenu=zh_CN.UTF-8
    set helplang=cn
    set foldmethod=indent
    map <F9>  :call ComC()<CR>
    imap <F9> <Esc><F9>
    map <F2>  :call Compy()<CR>
    imap <F2> <Esc><F2>
    map <F3>  :call ComTex()<CR>
    imap <F3> <Esc><F3>
    map <F10> :vsp %<.in<CR>:w<CR>:sp %<.out<CR>:w<CR>
    imap <F10> <Esc><F11>
    map<F4> :call Compy3()<CR>
    imap<F4> <Esc><F4>
    "map <F9>  <Esc>:w<CR>:!g++ % -Dylx -O2 -o %< && ./%<<CR>   
    "map <F9>  : call Com()<CR>: call Run()<CR>
    "map <F9>  :w<CR>:!g++ % -o ./%< && !./%<<CR>
    map <F12> :call Ts()<CR>
    "exec 'cd' . fnameescape(' Program')
    "imap<F8> : call SetTitle()<CR>

    imap<F8> /*<CR>Author: ylx<CR>Lang: c++<CR><Esc>:4 !echo %<<CR>0i * Prog: <Esc>$a<CR>/<CR>#include<bits/stdc++.h><CR>#define ll long long<CR>using namespace std;<CR>void qmax(int &x,int y) {if (x<y) x=y;}<CR>void qmin(int &x,int y) {if (x>y) x=y;}<CR>inline int read()<CR>{<CR>char s;<CR>int k=0,base=1;<CR>while ((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));<CR>if (s==EOF) exit(0);<CR>if (s=='-') base=-1,s=getchar();<CR>while (isdigit(s)) k=k*10+(s^'0'),s=getchar();<CR>return k*base;<CR>}<CR>inline void write(int x)<CR>{<CR>static char cnt,num[15];cnt=0;<CR>if (!x)<CR>{<CR>putchar('0');<CR>return;<CR>}<CR>for (;x;x/=10) num[++cnt]=x%10;<CR>for (;cnt;putchar(num[cnt--]+48));<CR>}<CR>int main()<CR>{<CR>#ifdef ylx<CR><Esc>:35 !echo %< <CR>$a.in<Esc>0i<Tab>freopen("<Esc>$a","r",stdin);<CR><Esc>:36 !echo %< <CR>$a.out<Esc>0i<Tab>freopen("<Esc>$a","w",stdout);<CR>#endif<CR>return 0;<CR>}<Esc>:r !date<CR>i//<Esc>:vsp %<.in<CR>:w<CR>:sp %<.out<CR>:w<CR>

    function! Compy()
        exec "w"
            exec "!python ./%"
            endfunction
            function! Compy3()
        exec "w"
            exec "!python3 ./%"
            endfunction
            function! ComTex()
        exec "w"    
            exec "!xelatex % %<.pdf"
                exec "!evince %<.pdf"
                endfunction
                function! ComC()
        exec "w"    
            exec "!g++ % -o ./%< -O2 -lm -Wall -std=c++11 -Dylx"
                exec "!./%<"
                endfunction

                function! Ts()
        exec"set expandtab"
            exec":%ret! 4"
            endfunction
            function! Run()
    "   exec "w"

    endfunction
    set enc=utf-8
    set fencs=utf-8,gbk,big5,cp936,gb18030,gb2312,utf-16
    set fenc=utf-8


Plugin 'wakatime/vim-wakatime'