vim配置python开发环境

最终配置图

下面的操作建立在已经装好vim下:(如果没装好,可使用apt install vim 或者yum install vim进行安装)

使用配色文件monokai.vim(https://git.oschina.net/nanxun/vim.git)

下载后,将此文件移动到/usr/share/vim/vim74/colors/ 目录下,因为我电脑里是vim7.4,所以这里是vim74

接下来使用这个配色

打开.vimrc:

vim ~/.vimrc

colorscheme monokai #引用刚刚放的配色

接下来是一些基础的配置

 set shortmess=atI   " 启动的时候不显示那个援助乌干达儿童的提示  
 set scrolloff=3     " 光标移动到buffer的顶部和底部时保持3行距离 
autocmd InsertLeave * se nocul  " 用浅色高亮当前行 
 set cursorline              " 突出显示当前行
 set magic                   " 设置魔术
 set syntax=on            ''设置语法高亮
 set autoindent                            ''设置自动缩进
 set tabstop=4                                ''设置tab格式
 set softtabstop=4
 set history=1000                            ''设置历史记录1000条
 set langmenu=zh_CN.UTF-8      ''设置支持utf-8

设置文件头

func SetTitle()  
        "如果文件类型为.sh文件  
        if &filetype == 'python'  
        call setline(1,"\#!/usr/bin/python3")
                call setline(2, "\#coding=utf8")  
                call setline(3, "\"\"\"")  
                call setline(4, "\# Author: cb")  
                call setline(5, "\# Created Time : ".strftime("%c"))  
                call setline(6, "")  
                call setline(7, "\# File Name: ".expand("%"))  
                call setline(8, "\# Description: Life is too short,Python as a song!")  
                call setline(9, "")  
                call setline(10, "\"\"\"")  
                call setline(11,"")  
        endif  
        if &filetype == 'java'  
                call setline(1, "//coding=utf8")  
                call setline(2, "/*************************************************************************")  
                call setline(3, "\ @Author: cb")  
                call setline(4, "\ @Created Time : ".strftime("%c"))  
                call setline(5, "")  
                call setline(6, "\ @File Name: ".expand("%"))  
                call setline(7, "\ @Description:")  
                call setline(8, "")  
                call setline(9, " ************************************************************************/")  
                call setline(10,"")  
        endif  
    
    if &filetype == 'sh'
    
                call setline(1, "#!/bin/bash")  
                call setline(2, "#/*************************************************************************")  
                call setline(3, "\# @Author: cb")  
                call setline(4, "\# @Created Time : ".strftime("%c"))  
                call setline(5, "")  
                call setline(6, "\# @File Name: ".expand("%"))  
                call setline(7, "\# @Description: Life is too short!")  
                call setline(8, "")  
                call setline(9, "#************************************************************************/")  
                call setline(10,"")  
    endif
endfunc  

" modify the last modified time of a file  
function SetLastModifiedTime(lineno)  
        let modif_time = strftime("%c")  
        if a:lineno == "-1"  
                let line = getline(6)  
        else  
                let line = getline(a:lineno)  
        endif      
        if line =~ '^\sLast Modified'  
                let line = substitute( line,':\s\+.*\d\{4\}', ':'.modif_time, "" )  
        else  
                let line = '  Last Modified: '.modif_time  
        endif  
        if a:lineno == "-1"  
                call setline(5, line)  
        else  
                call append(a:lineno, line)  
        endif  
endfunction  

效果如下

安装插件

我们这里使用Vundle  来安装插件

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
将下面的Vundle配置加到.vimrc文件中
set nocompatible              " required
filetype off                  " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
call vundle#end()            " required
filetype plugin indent on    " required
自动缩进插件:
Plugin 'vim-scripts/indentpython.vim'
自动补全插件:https://github.com/Valloric/YouCompleteMe#mac-os-x-super-quick-installation
Bundle 'Valloric/YouCompleteMe'
语法检查/高亮:
Plugin 'scrooloose/syntastic'
将上面的Plugin '***'都加入到.vimrc 进入vim 切换到命令模式,运行PluginInstall ,vim自动会将插件装好
相关配置文件放在码云了https://git.oschina.net/nanxun/vim.git

转载于:https://my.oschina.net/u/3264690/blog/873112

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值