vimrc同步文档

Posted ims-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vimrc同步文档相关的知识,希望对你有一定的参考价值。

目录

18.04 content

if has("syntax")  
syntax on  
endif  
" Source a global configuration file if available  
if filereadable("/etc/vim/vimrc.local")  
source /etc/vim/vimrc.local  
endif  
 
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 nu           "show line number  
set nobackup        "no backup  
"set cursorline       "high this line  
set ruler            "show cursor site in right below   
autocmd InsertLeave * se nocul  " 用浅色高亮当前行  
set tabstop=4      " 统一缩进为4  
set shiftwidth=4  

set pastetoggle=<F6> "插入模式粘贴不会自动缩进避免混乱  
set autoindent    "自动缩进  
set cindent  

"set foldenable " 开始折叠  
"set foldmethod=syntax " 设置语法折叠  
set foldcolumn=0 " 设置折叠区域的宽度  
setlocal foldlevel=1 " 设置折叠层数  
set foldopen=all     "光标到达折叠快时,自动打开  
"set foldclose=all    " 离开代码块后,自动折叠  

" 用空格键来开关折叠  
nnoremap <space> @=((foldclosed(line(‘.‘)) < 0) ? ‘zc‘ : ‘zo‘)<CR>  

set autoread  " 设置当文件被改动时自动载入  

set completeopt=longest,menu  
set completeopt=preview,menu "代码补全   
set nocompatible "取消vi 兼容模式  

"start----- 自动补全  -----------------
: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
"end------------------------------------------
  

"----- 打开文件类型检测-----------------
filetype plugin indent on
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>  
  
"start---------- definition  SetTitle() ------------------------------------ 
  
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java  exec ":call SetTitle()"  
func SetTitle()   
    if &filetype == ‘sh‘   
        call setline(1,"#########################################################################")  
        call append(line("."), "# File Name: ".expand("%"))  
        call append(line(".")+1, "# Author: ims")  
        call append(line(".")+2, "# Created Time: ".strftime("%c"))  
        call append(line(".")+3, "#########################################################################")  
        call append(line(".")+4, "#!/bin/bash")  
        call append(line(".")+5, "")  
    else  
        call setline(1, "/*************************************************************************")  
        call append(line("."), "    > File Name: ".expand("%"))  
        call append(line(".")+1, "    > Author: ims")  
        call append(line(".")+2, "    > Created Time: ".strftime("%c"))  
        call append(line(".")+3, " ************************************************************************/")  
        call append(line(".")+4, "")  
    endif  

    if &filetype == ‘cpp‘  
        call append(line(".")+5, "#include<iostream>")  
        call append(line(".")+6, "using namespace std;")  
        call append(line(".")+7, "")  
        call append(line(".")+8, "int main()")  
        call append(line(".")+9, "{")  
        call append(line(".")+10, "	")  
        call append(line(".")+11, "	return 0;")  
        call append(line(".")+12, "}")  
    endif

    if &filetype == ‘c‘
        call append(line(".")+5, "#include<stdio.h>")  
        call append(line(".")+6, "")  
        call append(line(".")+7, "")  
        call append(line(".")+8, "int main()")  
        call append(line(".")+9, "{")  
        call append(line(".")+10, "	")  
        call append(line(".")+11, "	return 0;")  
        call append(line(".")+12, "}")  
    endif

    normal 12G"
endfunc
  
"end----------- SetTitle() --------------------------------

"start------- set title of file of .py ----------
autocmd BufNewFile *.py  exec ":call SetTitleOfFilePy()"  
func SetTitleOfFilePy()   
    call setline(1,"#! /usr/bin/python3.5")  
    call append(line("."), "# -*- coding: UTF-8 -*-")  
    call append(line(".")+1, "####################################################################")  
    call append(line(".")+2, "# File Name: ".expand("%"))  
    call append(line(".")+3, "# Author: ims")  
    call append(line(".")+4, "# Created Time: ".strftime("%c"))  
    call append(line(".")+5, "####################################################################")  
    call append(line(".")+6, "")  
    call append(line(".")+7, "")  
    normal 9G  
endfunc  
"end--------------------------------------------
      

 
"start------运行.c/.cpp/.java/.sh文件-----------------

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‘  
        exec "!chmod +x %"   
        :!./%  
    endif  
endfunc 

"notice: csdn复制后<CR>  后面会有2个空格,要删除,不然,运行后直接回到编辑界面 
"end------------------------------------------

"start------运行.py 文件 <F4> ----------------

map <F4> :call RunPy()<CR>  
func! RunPy()  
    exec "w"  
    exec "!chmod +x %"  
    :!./%  
endfunc
"end-----------------------------------

"start------------调试C/C++ 绑定<F8>---------------
    map <F8> :call Rungdb()<CR>  
    func! Rungdb()  
        exec "w"  
        exec "!g++ % -g -Wall -o %<"  
        exec "!gdb ./%<"  
    endfunc  
"end---------------------------------------------------

let Tlist_Show_One_File=1 

let Tlist_Exit_OnlyWindow=1
" Open and close all the three plugins on the same time 
nmap <F8>   :TrinityToggleAll<CR> 

" Open and close the srcexpl.vim separately 
nmap <F9>   :TrinityToggleSourceExplorer<CR> 

" Open and close the taglist.vim separately 
nmap <F10>  :TrinityToggleTagList<CR> 

" Open and close the NERD_tree.vim separately 
nmap <F11>  :TrinityToggleNERDTree<CR> 

redhat


以上是关于vimrc同步文档的主要内容,如果未能解决你的问题,请参考以下文章

VIM 代码片段插件 ultisnips 使用教程

[工作积累] UE4 并行渲染的同步 - Sync between FParallelCommandListSet & FRHICommandListImmediate calls(代码片段

我的VIM -- vimrc配置

使用 Python 代码片段编写 LaTeX 文档

Word 文档的优秀代码片段工具或插件?

将点文件与 Dropbox 同步 [关闭]