vim of Windows programming

I've not handle a problem that can not vim how the compiler.

Basic programming know how, just the command line programming a little bit uncomfortable, but it's actually used Linux Well, I also see a lot of big brothers write the configuration file, simply because they do not understand, but with too much self-defeating, so I first wrote out my profile, if you want to configure after first use, there is pressure to go to study big brother wrote

Given their strength, but there are alternatives, I do not want to get another, and spent one hour, and I configured the program is very simple, you can complement brackets, a key to run the code. However, except for some basic items to use IDE, other small programs I basically use it to write, but to write Java a little uncomfortable, wrap trouble guide

source $VIMRUNTIME/vimrc_example.vim

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction
set nu!            "设置行号
colorscheme desert     "设置配色方案
syntax on         "语法高亮
syntax enable        set nobackup        "不生成备份文件
set showmatch        "设置匹配模式
set smartindent        "设置只能对齐
set ai!            "设置自动缩进
set fileencodings=utf-8,gbk
set ambiwidth=double    "设置中文支持
set guifont=consolas:h12 "设置字体及大小
set mouse=a        "启用鼠标
set spell spelllang=en_us
set undofile
set history=1000
set wildmenu
set wildmode=longest:list,full
set tabstop=2
set shiftwidth=4
set showmatch
nmap <leader>w :w!<cr>
nmap <leader>f :find<cr>

" 映射全选+复制 ctrl+a
map <C-A> ggVGY
map! <C-A> <Esc>ggVGY
map <F12> gg=G
" 选中状态下 Ctrl+c 复制
vmap <C-c> "+y
vmap <C-v> "+p
nmap <C-z> u

map  ddf <Esc>
omap ddf <Esc>
imap ddf <Esc>
cmap ddf <Esc>
"列出当前目录文件  
map <F3> :tabnew .<CR>  
"打开树状文件目录  
map <C-F3> \be  
"代码补全 
set completeopt=preview,menu 
"允许插件  
filetype plugin on
"共享剪贴板  
set clipboard+=unnamed 
" 不要使用vi的键盘模式,而是vim自己的
set nocompatible
"自动补全
: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 


map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        exec "!gcc % -o %<"
        exec "! %<"
    elseif &filetype == 'cpp'
        exec "!gcc % -o %<"
        exec "! %<"
    elseif &filetype == 'java' 
        exec "!javac %" 
        exec "!java %<"
    elseif &filetype == 'sh'
        :!%
    endif
endfunc


"C,C++debug
map <F8> :call Rungdb()<CR>
func! Rungdb()
    exec "w"
    exec "!g++ % -g -o %<"
    exec "!gdb %<"
endfunc

" <F5> 运行python程序
map <F6> :w<cr>:!python %<cr>

ps: I think the novice better spent half an hour with a sublime it

Guess you like

Origin www.cnblogs.com/xiaolongdejia/p/11327030.html