Vim编辑器基本设置

Vim编辑器基本设置

"设置编码
set encoding=utf-8  
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set fileformats=unix,dos,mac  
set termencoding=utf-8                                                                                                                                     
set formatoptions+=m
set formatoptions+=B

"显示行号
set ruler                       " show the current row and column "
set number                      " show line numbers "
set nowrap          
set showcmd                     " display incomplete commands "                                                                                          
set showmode                    " display current modes "
set showmatch                   " jump to matches when entering parentheses "
set matchtime=2 
"突出显示光标
set cursorcolumn
set cursorline

"Tab制表符设置
set expandtab                   " expand tabs to spaces "
set smarttab        
set shiftround

"查找配置
set hlsearch                    " highlight searches "
set incsearch                   " do incremental searching, search as you type "
set ignorecase                  " ignore case when searching "
set smartcase                   " no ignorecase if Uppercase char present "

"其用鼠标
set mouse=a
set selection=exclusive
set selectmode=mouse,key

"显示括号匹配
set showmatch

"设置缩进
set autoindent smartindent shiftround                                                                                                                      
set shiftwidth=4    
set tabstop=4       
set softtabstop=4                " insert mode tab and backspace use 4 spaces "

"设置粘贴格式
set paste

"显示空格和tab键
set listchars=tab:>-,trail:-

"总是显示状态栏
set laststatus=2
"显示光标当前位置
set ruler

set nocompatible                " don't bother with vi compatibility "
set autoread                    " reload files when changed on disk, i.e. via `git checkout` "
set shortmess=atI   
                    
set magic                       " For regular expressions turn magic on "
set title                       " change the terminal's title "
set nobackup                    " do not keep a backup file "                                                                                           
                    
set noerrorbells                " don't beep "
set visualbell t_vb=            " turn off error beep/flash "
set t_vb=           
set timeoutlen=500

"打开文件类型检测"
filetype on
filetype plugin on
filetype indent on

autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd

autocmd BufNewFile *.py,*.sh exec ":call AutoSetFileHead()"
function! AutoSetFileHead()
    " .sh "
    if &filetype == 'sh'
        call setline(1, "\#!/bin/bash")
    endif                                                                                                                                                  
         
    " python "     
    if &filetype == 'python'
        call setline(1, "\#!/usr/bin/env python")
        call append(1, "\# encoding: utf-8")
    endif

    normal G
    normal o
    normal o
endfunc

autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
fun! <SID>StripTrailingWhitespaces()
    let l = line(".")                                                                                                                                      
    let c = col(".")
    %s/\s\+$//e     
    call cursor(l, c)
endfun
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值