码迷,mamicode.com
首页 > 系统相关 > 详细

本人的 $vim$ 配置, 仅供参考

时间:2018-11-06 18:15:31      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:nerd   themes   bundle   fast   设置   避免   arc   odi   div   

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 基础设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible         " 设置不兼容原始vi模式
filetype on              " 设置开启文件类型侦测
filetype plugin on       " 设置加载对应文件类型的插件
set noeb                 " 关闭错误的提示 syntax enable            " 开启语法高亮功能
syntax on                " 自动语法高亮
set t_Co=256             " 开启256色支持
let g:rehash256 = 1
color molokai
packadd termdebug        " 开启Termbug调试
set cmdheight=2          " 设置命令行的高度
set showcmd              " select模式下显示选中的行数
set ruler                " 总是显示光标位置
set laststatus=2         " 总是显示状态栏
set number               " 开启行号显示
set cursorline           " 高亮显示当前行
highlight CursorLine   cterm=NONE ctermbg=black guibg=NONE guifg=NONE
                         " 高亮显示当前行具体设置
set cursorcolumn
highlight Cursorcolumn   cterm=NONE ctermbg=black guibg=NONE guifg=NONE
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ [%{(&fenc==\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}]\ %c:%l/%L%)
                         " 设置状态行显示的信息
set whichwrap+=<,>,h,l   " 设置光标键跨行
set ttimeoutlen=0        " 设置<ESC>键响应时间
set mouse=a              " 开启鼠标支持
set backspace=indent,eol,start 
                         " 允许删除换行符
set hidden               " 文件未保存时切换缓冲区由vim保存
set display=lastline     " 避免折行后某一行不见
set fillchars=vert:\ ,stl:\ ,stlnc:\   
                         " 在分割窗口间留出空白
set autochdir            " 移至当前文件所在目录
set wildmenu             " 开启zsh支持
set wildmode=full        " zsh补全菜单

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 快捷键设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = "`"      " 定义<leader>键
nnoremap <c-h> <c-w>h  
nnoremap <c-l> <c-w>l  
nnoremap <c-j> <c-w>j  
nnoremap <c-k> <c-w>k
                         " 窗口切换 
inoremap <Up> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
inoremap <Down> <Nop>
                         " 使方向键无效(适应vim)

inoremap { {<CR>}<ESC>kA

nnoremap j gj
nnoremap gj j
nnoremap gk k
nnoremap k gk
                         " 移动对应屏幕行

map <leader>1 :call Compile()<CR>
func! Compile()
    exec ‘w‘
    exec ‘!g++ -g -Wall -lm % -o %< -O2‘
endfunc

map <leader>2 :call Run()<CR>
func! Run()
    exec ‘!time ./%<‘
endfunc

map <leader>3 :call Divide()<CR>
func! Divide()
    exec ‘vsp %<.out‘
    exec ‘w‘
    exec ‘vertical resize -40‘
    exec ‘sp %<.in‘
    exec ‘w‘
endfunc

map <leader>4 <C-w>h:wq<CR>:wq<CR>

map zz zf%
map zx zd

map <c-n> :call SetTitle()<CR>

map <F3> :NERDTreeToggle<CR>
                         " F3开启目录树nerdtree插件

map <F5> :Termdebug %<<CR>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 代码缩进和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cindent              " 设置使用C/C++语言的自动缩进方式
set cinoptions+=(0,:0,g0
                         " N-s设置C/C++语言的具体缩进方式
set smartindent          " 智能的选择对其方式
filetype indent on       " 自适应不同语言的智能缩进
set tabstop=4            " 设置编辑时制表符占用空格数
set shiftwidth=4         " 设置格式化时制表符占用空格数
set softtabstop=4        " 设置4个空格为制表符
set smarttab             " 在行和段开始处使用制表符
set backspace=2          " 使用回车键正常处理indent,eol,start等
set sidescroll=10        " 设置向右滚动字符数
set fdm=marker
set history=2000         " 历史ex命令记录上限提高
set scrolloff=6          " 上下可视行数
set showmatch            " 高亮显示匹配括号
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 搜索设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hlsearch            " 高亮显示搜索结果
set incsearch           " 开启实时搜索功能
set ignorecase          " 搜索时大小写不敏感
set nowrapscan          " 搜索到文件两端停止
set incsearch           " 实时搜索

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 缓存设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup            " 设置不备份
set noswapfile          " 禁止生成临时文件
set autoread            " 文件在vim之外修改过,自动重新读入
set autowrite           " 设置自动保存
set confirm             " 在处理未保存或只读文件的时候,弹出确认

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 编码设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set langmenu=zh_CN.UTF-8
set helplang=cn
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 插件列表
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin ‘VundleVim/Vundle.vim‘                    " 使用Vundle的必须配置
Plugin ‘chxuan/vimplus-startify‘                 " 启动界面
Plugin ‘scrooloose/nerdtree‘                     " 目录树
Plugin ‘tiagofumo/vim-nerdtree-syntax-highlight‘ " 目录树美化
Plugin ‘vim-airline/vim-airline‘                 " 状态栏美化
Plugin ‘vim-airline/vim-airline-themes‘          " 状态栏美化主题
Plugin ‘tpope/vim-commentary‘                    " 快速注释
Plugin ‘w0rp/ale‘                                " 语法查错
Plugin ‘Lokaltog/vim-easymotion‘                 " 快速跳转
Plugin ‘luochen1990/rainbow‘                     " 彩虹括号
Plugin ‘yianwillis/vimcdoc‘                      " HELP文档中文
Plugin ‘suan/vim-instant-markdown‘               " markdown 实时预览
Plugin ‘vim-scripts/taglist‘

call vundle#end()            
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 插件设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" airline 设置
if filereadable(expand($HOME . ‘/.vimrc.airline‘))
    source $HOME/.vimrc.airline
endif

" rainbow
let g:rainbow_active = 1

" Nerdtree设置
if filereadable(expand($HOME . ‘/.vimrc.nerdtree‘))
    source $HOME/.vimrc.nerdtree
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 新文件标题
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile *.cpp exec ":call SetTitle()"
func! SetTitle()
    if &filetype==‘cpp‘
        call append(0,"/**********************************************************")
        call append(1," * Author        : EndSaH")
        call append(2," * Email         : 2499808100@qq.com")
        call append(3," * Created Time  : ".strftime("%Y-%m-%d %H:%M"))
        call append(4," * FileName      : ".expand("%:t"))
        call append(5," * *******************************************************/")
        call append(6,"")
        call append(7,"#include <cstdio>")
        call append(8,"#include <cctype>")
        call append(9,"")
        call append(10,"#define file")
        call append(11,"")
        call append(12,"class Fast_IO")
        call append(13,"{")
        call append(14,"    enum { MAX = 10000000 };")
        call append(15,"")
        call append(16,"    char *ipos, *iend, *opos, *oend, *stkpos;")
        call append(17,"    char ibuf[MAX], obuf[MAX], stk[40]; ")
        call append(18,"")
        call append(19,"public :")
        call append(20,"    Fast_IO()")
        call append(21,"    {")
        call append(22,"        ipos = iend = ibuf;")
        call append(23,"        opos = obuf, oend = obuf + MAX;")
        call append(24,"        stkpos = stk;")
        call append(25,"    }")
        call append(26,"")
        call append(27,"    ~Fast_IO()")
        call append(28,"    {")
        call append(29,"        fwrite(obuf, 1, opos - obuf, stdout);")
        call append(30,"    }")
        call append(31,"")
        call append(32,"    char Getchar()")
        call append(33,"    {")
        call append(34,"        return ipos == iend and (iend = (ipos = ibuf) + fread(ibuf, 1, MAX, stdin), ipos == iend) ? EOF : *ipos++;")
        call append(35,"    }")
        call append(36,"")
        call append(37,"    void Putchar(char c)")
        call append(38,"    {")
        call append(39,"        if(opos == oend)")
        call append(40,"        {")
        call append(41,"            fwrite(obuf, 1, MAX, stdout);")
        call append(42,"            opos = obuf;")
        call append(43,"        }")
        call append(44,"        *opos++ = c;")
        call append(45,"    }")
        call append(46,"")
        call append(47,"    Fast_IO& operator>>(int& num)")
        call append(48,"    {")
        call append(49,"        register char c;")
        call append(50,"        register int flag = 1;")
        call append(51,"        num = 0;")
        call append(52,"        while(!isdigit(c = Getchar()))")
        call append(53,"            if(c == ‘-‘)")
        call append(54,"                flag = -1;")
        call append(55,"        while(num = (num << 3) + (num << 1) + (c ^ 48), isdigit(c = Getchar()));")
        call append(56,"        num *= flag;")
        call append(57,"        return *this;")
        call append(58,"    }")
        call append(59,"")
        call append(60,"    Fast_IO& operator<<(int num)")
        call append(61,"    {")
        call append(62,"        if(num < 0)")
        call append(63,"        {")
        call append(64,"            Putchar(‘-‘);")
        call append(65,"            num = -num;")
        call append(66,"        }")
        call append(67,"        do")
        call append(68,"        {")
        call append(69,"            *++stkpos = num % 10 ^ 48;")
        call append(70,"            num /= 10;")
        call append(71,"        } while(num);")
        call append(72,"        while(stkpos != stk)")
        call append(73,"            Putchar(*stkpos--);")
        call append(74,"        return *this;")
        call append(75,"    }")
        call append(76,"")
        call append(77,"    Fast_IO& operator<<(char c)")
        call append(78,"    {")
        call append(79,"        Putchar(c);")
        call append(80,"        return *this;")
        call append(81,"    }")
        call append(82,"} wib;")
        call append(83,"")
        call append(84,"int main()")
        call append(85,"{")
        call append(86,"#ifdef file")
        call append(87,"#endif")
        call append(88,"}")
        normal 87G
    endif
endfunc
autocmd BufNewFile * normal Gdd14Gzz87G

本人的 $vim$ 配置, 仅供参考

标签:nerd   themes   bundle   fast   设置   避免   arc   odi   div   

原文地址:https://www.cnblogs.com/EndSaH/p/9916845.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!