作者:Xlady贩卖__铺 | 来源:互联网 | 2023-09-23 14:11
此配置目前使用户mac,linux,win,但是win系统的c++调用需要单独手动配置。 SettingsomedecentVIMsettingsforprogramming
此配置目前使用户mac,linux,win,但是win系统的c++调用需要单独手动配置。
" 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 defaultsset mouse= " Reset the mouse setting from defaultsaug vimStartup | au! | aug END " Revert last positioned jump, as it is defined belowlet g:skip_defaults_vim = 1 " Do not source defaults.vim again (after loading this system vimrc)
set ai " set auto-indenting on for programmingset 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 alwaysset showmode " show the current modeset clipboard=unnamed " set clipboard to unnamed to access the system clipboard under windowsset wildmode=list:longest,longest:full " Better command line completion
" Show EOL type and last modified timestamp, right after the filename" Set the statuslineset statusline=%f " filename relative to current $PWDset statusline+=%h " help file flagset statusline+=%m " modified flagset statusline+=%r " readonly flagset statusline+=\ [%{&ff}] " Fileformat [unix]/[dos] etc...set statusline+=\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))}) " last modified timestampset statusline+=%= " Rest: right alignset statusline+=%l,%c%V " Position in buffer: linenumber, column, virtual columnset 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 minttyendif"------------------------------------------------------------------------------" 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 enableset numberset cursorlineset ruler"set shift==========================================" 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 nobackupset noswapfile" create undo fileset undolevels=1000 " how many undosset undoreload=10000 " number of lines to save for undoif v:version >= 730set undofile " keep a persistent backup fileset 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,这里是2set 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" 当搜索的时候尝试smarset smartcase" 设置代码折叠"set foldenable" 折叠方法" manual 手工折叠" indent 缩进折叠" expr 表达式折叠" syntax 语法折叠" diff 对没有更改的文件折叠" marker 标记折叠"set foldmethod=inden"set foldlevel=99" 设置C/C++方式自动对齐set autoindentset cindentset smartindent" 设置tab宽度set tabstop=4" 设置自动对齐空格数set shift 按退格键时可以一次删除4个空格"set softtabstop=4" 编辑的时候将所有的tab设置为空格(expandtab)set et" 使用Backspace直接删除tabset smarttab" 不在单词中间折行set lbr
"==========================================" FileEncode Settings"==========================================" 设置编码方式set encoding=utf-8" 设置打开文件的编码格式set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1set helplang=cn" 只对终端影响(默认)set termencoding=utf-8" use UNIX as the standard file typeset ffs=unix,dos,mac" 如遇Unicode值大于255的文本,不必等到空格再折行。set formatoptions+=m" 合并两行中文时,不在中间加空格:set formatoptions+=B
"==========================================" HotKey Settings"==========================================:set pastetoggle=
"==========================================" 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 fileif has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endifendif
func! CompileGcc() exec "w" let compilecmd="!gcc " let compileflag="-o %<" if search("glut\.h") != 0 let compileflag .= " -lglut -lGLU -lGL " endif exec compilecmd." % ".compileflagendfunc
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." % ".compileflagendfunc
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()" endifendfunc
func! RunResult() exec "w" if &filetype == "c" exec "! ./%<" elseif &filetype == "cpp" exec "! ./%<" elseif &filetype == "python" exec "call RunPython" elseif &filetype == "java" exec "!java %<" endifendfunc
map :call RunResult()map :call CompileCode()imap :call CompileCode()vmap :call CompileCode()
pasting