vim 的常用配置

整理一下自己经常用到的一些设置,要保存在 .vimrc 中
具体有
1)从其他地方复制造成的问题
2)tab 转4个空格
3)记住上次打开的位置
4)F5直接运行各种脚本

” 很早以前记下的,应该是把tab转为空格,可能还有解决复制错行的问题
set nocompatible
set backspace=indent,eol,start
set autoindent
set softtabstop=4
set shiftwidth=4
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
if &term=="xterm"
    set t_Co=8
             set t_Sb=^[[4%dm
    set t_Sf=^[[3%dm
endif
“ 开启行号显示
set nu
” 解决打开文件乱码? (很早之前记的)
set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
set pastetoggle=
“ 
” 打开记住上次打开的位置
set viminfo='10,\"100,:20,%,n~/.viminfo 
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

:set ts=4
:set expandtab
:%retab!

” 最近经常用到的,非常好用的编译运行功能
" 原文:https://blog.csdn.net/zijin0802034/article/details/77709465
map    :call CompileRunGcc()

func! CompileRunGcc()
    exec "w" 
    if &filetype == 'c' 
        exec '!g++ % -o %<'
        exec '!./%<'
    elseif &filetype == 'cpp'
        exec '!g++ % -o %<'
        exec '!./%<'
    elseif &filetype == 'ruby'
        exec '!ruby %'
    elseif &filetype == 'python'
        exec '!python %'
    elseif &filetype == 'sh'
        :! bash %
    endif
endfunc

你可能感兴趣的:(软件环境配置)