zoukankan      html  css  js  c++  java
  • vim配置文件

    进行配置的时候输入命令行vim .vimrc,在里面写vim的配置文件

    tabstop:制表符的长度

    shiftwidth:自动缩进的长度

    colorscheme ron: 主题选用ron(我个人比较喜欢这个)

    inoremap A B:在插入模式下将A映射为B

    map A B:在命令模式下将A映射为B

    Code

    set nu "显示行号
    set ts=4 "ts是tabstop的简写
    set sw=4 "sw是shiftwidth的简写
    set mouse=a "可以使用鼠标
    set cindent "使用C语言格式的自动缩进
    set autoindent "可以自动缩进
    
    color ron "color是colorscheme的简写
    
    ino ' ''<esc>i
    ino " ""<esc>i
    ino ( ()<esc>i
    ino [ []<esc>i
    ino { {}<esc>i
    ino {<cr> {<cr>}<esc>O
    "括号补全,ino是inoremap的简写
    
    ino jk <esc>:w<cr>
    "进入命令模式并保存
    ino jl <end>
    ino jo <home>
    "个人喜好,将比较远的键映射一下
    
    ino <C-h> <left>
    ino <C-j> <down>
    ino <C-k> <up>
    ino <C-l> <right>
    "映射方向键(<C-h>表示Ctrl+h),这个可能用不习惯,可以不用
    
    ino <F5> <esc>:call Run()<cr>
    map <F5> :call Run()<cr>
    func Run()
        exec "w"
        exec "!g++ % -o %< && time ./%< < in"
    endf
    "按F5进行编译运行
    "time 可以显示运行时间(ms)
    " < in 表示从 in 中读入
    
    ino <F7> <esc>:call Gdb()<cr>
    map <F7> :call Gdb()<cr>
    func Gdb()
        exec "w"
        exec "!g++ % -o %< -g && gdb %<"
    endf
    "按F7进行调试
    
    ino <F9> <esc>:call Cat()<cr>
    map <F9> :call Cat()<cr>
    func Cat()
        exec "w"
        exec "!cat %"
    endf
    "按F9可以将文件打出来,这是对于不方便复制的时候,用不到的话可以忽略
    
    autocmd BufNewFile *.cpp exec ":call SetTitle()" 
    func SetTitle() 
        if &filetype == 'cpp'
            call setline(1,"#include <cstdio>")
            call append(line("."), "")
            call append(line(".")+1, "const int N = ;")
            call append(line(".")+2, "")
            call append(line(".")+3, "int read(int x = 0, int f = 1, char c = getchar()) {")
            call append(line(".")+4, "	for (; c < '0' || c > '9'; c = getchar())")
            call append(line(".")+5, "		if (c == '-') f = -1;")
            call append(line(".")+6, "	for (; c >='0' && c <='9'; c = getchar())")
            call append(line(".")+7, "		x = x * 10 + c - '0';")
            call append(line(".")+8, "	return x * f;")
            call append(line(".")+9, "}")
            call append(line(".")+10, "")
            call append(line(".")+11, "int main() {")
            call append(line(".")+12, "}")
        endif
    endfunc 
    
  • 相关阅读:
    tp5.1批量删除商品
    tp5.1 无限极分类前台展示
    jquery实现商品sku多属性选择(商品详情页)
    简单的权限管理php
    js的常用场景效果
    jquery 常用选择器基础语法学习
    js 注意事项使用误区
    js (单个的)点击式下拉菜单
    React中setState学习总结
    JavaScript面试核心考点(精华)
  • 原文地址:https://www.cnblogs.com/Z8875/p/vimrc.html
Copyright © 2011-2022 走看看