此配置目前使用户mac,linux,win,但是win系统需要提前配置mingw32相关的gcc系统路径等信息。

" Setting some decent VIM settings for programming
" This source file comes from git-for-windows build-extra repository (git-extra/vimrc)

ru! defaults.vim " Use Enhanced Vim defaults
set mouse= " Reset the mouse setting from defaults
aug vimStartup | au! | aug END " Revert last positioned jump, as it is defined below
let g:skip_defaults_vim = 1 " Do not source defaults.vim again (after loading this system vimrc)

set ai " set auto-indenting on for programming
set showmatch " automatically show matching brackets. works like it does in bbedit.
set vb " turn on the "visual bell" - which is much quieter than the "audio blink"
set laststatus=2 " make the last line where the status is two lines deep so you can see status always
set showmode " show the current mode
set clipboard=unnamed " set clipboard to unnamed to access the system clipboard under windows
set wildmode=list:longest,longest:full " Better command line completion

" Show EOL type and last modified timestamp, right after the filename
" Set the statusline
set statusline=%f " filename relative to current $PWD
set statusline+=%h " help file flag
set statusline+=%m " modified flag
set statusline+=%r " readonly flag
set statusline+=\ [%{&ff}] " Fileformat [unix]/[dos] etc...
set statusline+=\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))}) " last modified timestamp
set statusline+=%= " Rest: right align
set statusline+=%l,%c%V " Position in buffer: linenumber, column, virtual column
set statusline+=\ %P " Position in buffer: Percentage

if &term =~ 'xterm-256color' " mintty identifies itself as xterm-compatible
if &t_Co == 8
set t_Co = 256 " Use at least 256 colors
endif
" set termguicolors " Uncomment to allow truecolors on mintty
endif
"------------------------------------------------------------------------------
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Set UTF-8 as the default encoding for commit messages
autocmd BufReadPre COMMIT_EDITMSG,MERGE_MSG,git-rebase-todo setlocal fileencodings=utf-8

" Remember the positions in files with some git-specific exceptions"
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$")
\ && &filetype !~# 'commit\|gitrebase'
\ && expand("%") !~ "ADD_EDIT.patch"
\ && expand("%") !~ "addp-hunk-edit.diff" |
\ exe "normal g`\"" |
\ endif

autocmd BufNewFile,BufRead *.patch set filetype=diff

autocmd Filetype diff
\ highlight WhiteSpaceEOL ctermbg=red |
\ match WhiteSpaceEOL /\(^+.*\)\@<=\s\+$/
endif " has("autocmd")
syntax enable
set number
set cursorline
set ruler
"set shiftwidth=4

"==========================================
" Common Settings
"==========================================
" 开启语法高亮
syntax enable
" 开启语法高亮
syntax on
" 设置字体
set guifont=Monaco
" 设置历史记录条数
set history=999
" 检测文件类型
filetype on
" 针对不同的文件,采用不同的缩进方式
filetype indent on
" 允许插件
filetype plugin on
" 启动自动补全
filetype plugin indent on
" 文件修改之后自动读入
set autoread
" 启动后不显示提示
"set shortmess=atI
" 设置取消备份,禁止临时文件生成
set nobackup
set noswapfile
" create undo file
set undolevels=1000 " how many undos
set undoreload=10000 " number of lines to save for undo
if v:version >= 730
set undofile " keep a persistent backup file
set undodir=/tmp/vimundo/
endif
"set wildignore=*.swp,*.bak,*.pyc,*.class,.svn
" 显示当前横竖线
"set cursorline
"set cursorcolumn
" 设置退出Vim之后内容显示在终端屏幕,可以用于查看和复制
" 好处:误删什么,如果以前屏幕打开可以用来找回
"set t_ti= t_te=
" 设置在Vim中可以使用鼠标,防止终端无法拷贝
"set mouse=a

"==========================================
" Display Settings
"==========================================
" 显示当前行号和列号
set ruler
" 在状态栏显示正在输入的命令
set showcmd
" 左下角显示当前Vim模式
set showmode
" 光标移动至少保留的行数
"set scrolloff=7
" 命令行(在状态行下)的高度,默认为1,这里是2
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
" 总是显示状态栏(Powerline需要2行)
set laststatus=2
" 显示行号
set number
" 指定不折行
set nowrap
" 设置代码匹配,包括括号匹配情况
set showmatch
" how many tenths of a second to blink when matching brackets
" setmatchtime=2
" 开启及时搜索(is)
set incsearch
" 设置搜索高亮(hlsearch)
set hls
" 设置搜索时忽略大小写
set ignorecase
" 当搜索的时候尝试smar
set smartcase
" 设置代码折叠
"set foldenable
" 折叠方法
" manual 手工折叠
" indent 缩进折叠
" expr 表达式折叠
" syntax 语法折叠
" diff 对没有更改的文件折叠
" marker 标记折叠
"set foldmethod=inden
"set foldlevel=99
" 设置C/C++方式自动对齐
set autoindent
set cindent
set smartindent
" 设置tab宽度
set tabstop=4
" 设置自动对齐空格数
set shiftwidth=4
" 按退格键时可以一次删除4个空格
"set softtabstop=4
" 编辑的时候将所有的tab设置为空格(expandtab)
set et
" 使用Backspace直接删除tab
set smarttab
" 不在单词中间折行
set lbr

"==========================================
" FileEncode Settings
"==========================================
" 设置编码方式
set encoding=utf-8
" 设置打开文件的编码格式
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set helplang=cn
" 只对终端影响(默认)
set termencoding=utf-8
" use UNIX as the standard file type
set ffs=unix,dos,mac
" 如遇Unicode值大于255的文本,不必等到空格再折行。
set formatoptions+=m
" 合并两行中文时,不在中间加空格:
set formatoptions+=B

"==========================================
" HotKey Settings
"==========================================
:set pastetoggle=<F12>

"==========================================
" Theme Settings
"==========================================
" 设置主题
" set background=dark
" colorscheme evening
" set t_Co=256

"==========================================
" Other Settings
"==========================================
" Uncomment the following to have Vim jump to the last position when reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

func! CompileGcc()
exec "w"
let compilecmd="!gcc "
let compileflag="-o %< "
if search("glut\.h") != 0
let compileflag .= " -lglut -lGLU -lGL "
endif
exec compilecmd." % ".compileflag
endfunc

func! CompileGpp()
exec "w"
let compilecmd="!g++ -std=c++11 "
let compileflag="-o %< "
if search("glut\.h") != 0
let compileflag .= " -lglut -lGLU -lGL "
endif
exec compilecmd." % ".compileflag
endfunc

func! RunPython()
exec "!python %"
endfunc

func! CompileJava()
exec "!javac %"
endfunc

func! CompileCode()
exec "w"
if &filetype == "cpp"
exec "call CompileGpp()"
elseif &filetype == "c"
exec "call CompileGcc()"
elseif &filetype == "python"
exec "call RunPython()"
elseif &filetype == "java"
exec "call CompileJava()"
endif
endfunc

func! RunResult()
exec "w"
if &filetype == "c"
exec "! ./%<"
elseif &filetype == "cpp"
exec "! ./%<"
elseif &filetype == "python"
exec "call RunPython"
elseif &filetype == "java"
exec "!java %<"
endif
endfunc

map <F5> :call RunResult()<CR>
map <F9> :call CompileCode()<CR>
imap <F9> <ESC>:call CompileCode()<CR>
vmap <F9> <ESC>:call CompileCode()<CR>

pasting

vim用户设置的更多相关文章

  1. iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置

    1.enconv文件名编码转换,比如要将一个GBK编码的文件转换成UTF-8编码,操作如下 enconv -L zh_CN -x UTF-8 filename enconv -L GB2312 -x  ...

  2. WebStorm 自定义字体+颜色+语法高亮+导入导出用户设置

    WebStorm :是jetbrains公司旗下一款JavaScript 开发工具.被广大中国JS开发者誉为“Web前端开发神器”.“最强大的HTML5编辑器”.“最智能的JavaScript IDE ...

  3. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(22)-为用户设置角色

    ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)   (1):框架搭建    (2):数据库访问层的设计Demo    (3):面向接口编程   (4 ):业务逻辑层的封装    ...

  4. Vim 配色设置与配色脚本语法

    几个给tag加颜色的插件 https://github.com/octol/vim-cpp-enhanced-highlight:基于tag的c family语法高亮 https://github.c ...

  5. IPMI 配置BMC用户设置

    IPMI 配置BMC用户设置 本文档共介绍5条ipmi设置user的命令,这些命令需要使用root权限才能使用,其中- H为需要操作的BMC ip,-I lanplus为使用rmcp+协议发送命令,- ...

  6. vim高亮设置

    vim高亮设置 前提: 查看vim是否完整安装 rpm -qa | grep vim 若完整安装,则会出现如下相关信息 vim-filesystem-7.4.629-5.el6.x86_64 vim- ...

  7. VSCode插件及用户设置

    第一部分:插件 VSCode内置"emmet"插件,"convert to utf-8"等插件效果!十分强大!代码提示功能特别强悍! 插件地址:点击此处! 推荐 ...

  8. vim折叠设置(转载)

    vim折叠设置(转载) set foldmethod=indent "set default foldmethod"zi 打开关闭折叠"zv 查看此行zm 关闭折叠zM ...

  9. rabbitmq之后台管理和用户设置(三)

    前言 前面介绍了erlang环境的安装和rabbitmq环境安装,接下来介绍rabbitmq的web管理和用户设置. 启用后台管理插件 通过后台管理插件我们可以动态监控mq的流量,创建用户,队列等. ...

随机推荐

  1. [JZOJ 5788] 餐馆

    思路: 考虑树形dp. 我们设\(dp[i][j][0/1]\)表示在\(i\)为根的子树中花费\(j\)单位时间,最终回到/不必回到\(i\)的最大收益. 转移三种: \(dp[x][j][0] = ...

  2. 二分查找总结及部分Lintcode题目分析 3

    Search in rotated sorted array,题目中也给出了相应的例子,就是在sorted array某个节点发生了翻转(ie.0 1 2 4 5 6 7 might become 4 ...

  3. dart 异步

    使用异步有两种方法 then 或者 async/await. async/await 方法更易于理解,

  4. Vue的组件及传参

    目录 Vue的组件及传参 Vue组件的概念 根组件 子组件(局部组件) 父组件向子组件传值 子组件向父组件传值 Vue的组件及传参 Vue组件的概念 我们首先要知道组件的概念,实际上每一个组件都是一个 ...

  5. 单体内置对象——Global对象

    单体内置对象的定义:由ECMAScript实现提供的.不依赖于宿主环境的对象,这些对象在ECMAScript程序执行之前已经存在了.意思就是说:开发人员不必显式地实例化内置对象,因为他们已经实例化了. ...

  6. 学习 debug

    要在代码编辑器中设置源代码断点,有以下 4 种操作方式. (1) 把光标移到要设为断点的行上,按下 F5 键. (2) 用鼠标左键单击要设为断点的行的最左端. (3) 用鼠标右键单击要设为断点的行,在 ...

  7. js怎样截取字符串后几位以及截取字符串前几位

    想要截取字符串前几位与后几位,主要代码如下 截取字符串前几位 var disName ='开心一族漂亮家园'; var shortName = disName.substring(0,5); cons ...

  8. UVALive-3722 留个坑,为什么费马小定理求逆元不对??

    #include <iostream> #include <cstdlib> #include <queue> #include <algorithm> ...

  9. show master status

    只有在主库上执行才能有效抵输出: 具体文档如下: # 在127.:3306主库上执行 tmp@127.0.0.1 ((none))> show variables like '%server%' ...

  10. [JZOJ3293] 【SHTSC2013】阶乘字符串

    题目 题目大意 给你一个字符串,判断这个字符串是否为"阶乘字符串". 就是子序列包含字符集的全排列的字符串. n≤26n\leq 26n≤26 ∣S∣≤450|S|\leq 450 ...