• 配置文件 vim && gedit


    vim配置

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

    vimrc

    set nu "显示行号
    set cin "cin是cindnet的简写,使用C语言格式的自动缩进
    set hls "hls是hlsearsh的简写,启动搜索高亮
    set ts=4 "ts是tabstop的简写
    set sw=4 "sw是shiftwidth的简写,写set cin后用
    set mouse=a "可以使用鼠标
    
    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的简写
    
    map! jk <esc>:w<cr>
    "进入普通模式并保存
    "map! jl <end>
    "map! jo <home>
    "个人喜好,将比较远的键映射一下
    
    "map! <C-h> <left>
    "map! <C-j> <down>
    "map! <C-k> <up>
    "map! <C-l> <right>
    "映射方向键(<C-h>表示Ctrl+h),这个可能用不习惯,可以不用
    
    "map! <F5> <esc>:w<cr>:!g++ % -o %< -std=c++11 && time ./%< < IN<cr>
    "map! <F7> <esc>:w<cr>:!g++ % -o %< -g && gdb %<<cr>
    "map! <F6> <esc>:w<cr>:!python3 %<cr>
    "map! <F9> <esc>:w<cr>:!cat %<cr>
    
    map <F5> :w<cr>:!g++ % -o %< -std=c++11 && time ./%< < IN<cr>
    map <F7> :w<cr>:!g++ % -o %< -g && gdb %<<cr>
    "map <F6> :w<cr>:!python3 %<cr>
    map <F9> :w<cr>:!cat %<cr>
    "按F5进行编译运行cpp , time 可以显示运行时间(ms), < in 表示从 in 中读入
    
    "按F6运行python代码
    
    "按F7进行调试
    
    "按F9可以将文件打出来,方便复制到系统剪切板
    
    autocmd BufNewFile *.cpp exec ":call SetTitle()" 
    func SetTitle() 
        if &filetype == 'cpp'
            call setline(1,"#include <cstdio>")
            call append(line("."), "")
            call append(line(".")+1, "using namespace std;")
            call append(line(".")+2, "const int N = ;")
            call append(line(".")+3, "")
            call append(line(".")+4, "int read(int x = 0, int f = 1, char c = getchar()) {")
            call append(line(".")+5, "	for (; c < '0' || c > '9'; c = getchar())")
            call append(line(".")+6, "		if (c == '-') f = -1;")
            call append(line(".")+7, "	for (; c >='0' && c <='9'; c = getchar())")
            call append(line(".")+8, "		x = x * 10 + c - '0';")
            call append(line(".")+9, "	return x * f;")
            call append(line(".")+10, "}")
            call append(line(".")+11, "")
            call append(line(".")+12, "int main() {")
            call append(line(".")+13, "}")
        endif
    endfunc 
    

    一些不在我的配置文件的东西

    1. set ai ai是autoindent的简写,启动自动缩进

    2. set et et是expandtab的简写,制表符将由空格代替

    3. set noswapfile:不产生.swap文件

    4. tabstop:制表符的长度

    5. shiftwidth:自动缩进的长度

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

    关于键盘映射(map)

    1. :nmap 在普通模式(Normal)下映射

    2. :vmap 在可视化模式(Visual)下映射

    3. :omap 在运算符模式(Operator Pending)下映射

    4. :imap 在插入模式(Insert Only)下映射

    5. :cmap 在命令行模式(Command Line)下映射

    6. :map 相当与1,2,3和起来

    7. :map! 相当与4,5和起来

    8. :inoremap 是在插入模式下不递归的映射

    gedit配置

    首先要在首选项里开启外部工具的插件

    Run

    #!/bin/sh
    fullname=$GEDIT_CURRENT_DOCUMENT_NAME
    name=${fullname%.*}
    gnome-terminal -x bash -c "rm $name; make $name; time ./$name < IN; read"
    

    Gdb

    #!/bin/sh
    fullname=$GEDIT_CURRENT_DOCUMENT_NAME
    name=${fullname%.*}
    gnome-terminal -x bash -c "g++ $fullname -o $name -g; gdb $name; read"
    
  • 相关阅读:
    Docker版安装部署 Nexus 及阿里云仓库与本地仓库配置
    Golang开发中如何解决共享变量问题
    什么是dubbo?
    dubbo配置
    redis击穿,穿透,雪崩
    C#根据wsdl文件生成客户端调用代码
    查询哪个程序在使用某个端口
    Java面试题(十六):双亲委派模型
    Java面试题(十五):Java类加载器
    Java面试题(十四):什么是字节码?采用字节码的好处是什么?
  • 原文地址:https://www.cnblogs.com/shawk/p/vimrc.html
Copyright © 2020-2023  润新知