拥有一个更好的Vim编辑器

拥有一个更好的Vim编辑器用它写python

前言(不想看可以跳过):

第一,刚刚把火狐换谷歌(两个电脑同时换的 )想看看速度怎么样
最近把kali换成了ubuntu,换成了64位,原先的sublime不能用了。。。(百度的deb包)
于是只能试试Vim(毕竟老容易忘保存)

Vim的起源(不想看跳过,其实我也不太想看):

Vim的一个社区(https://www.osvim.org/vimcourse/23.html)

大致要求:

  1. 可以自动补‘()’‘【】’。。。。
  2. 有函数提醒
  3. 支持鼠标操作
  4. 拥有目录
  5. 可以内置终端(用于pip和apt)
  6. 自动加空格
  7. 一键运行
  8. 可以分屏
    总之和VScode差不多

最后效果:

Vim:
在这里插入图片描述
F1可以开终端
F2可以运行sh和python
F3可以打开目录
F4竖分屏
F5横分屏
vscode(对比):
在这里插入图片描述

很明显被VScode吊打,但毕竟还是Vim适合我linux那台电脑的内存条(只有2G)

开始配置(极度麻烦):

安装jedi(我怀疑这是一个星战的粉丝)

apt-get install jedi

建立一个文件夹和配置文件

mkdir ~/.vim
vim ~/.vimrc

安装插件就用git

git clone 插件地址 ~/.vim

地址(好像不止这两个。。。以后我再想想,有问题评论发一下):
https://github.com/Valloric/YouCompleteMe
https://github.com/scrooloose/nerdtree
当然,如果有vimogen会好很多,按照官网 的提示即可

其他配置

先用root打开文件管理器

sudo nautilus

找到/usr/share/vim/vim**/colors
把整个文件夹复制下来,放到你的.vim文件夹里,主题自己选

配置文件:

    inoremap ( ()<Esc>i
    inoremap [ []<Esc>i
    inoremap < <><Esc>i
    inoremap { {}<Esc>i
    inoremap ' ''<Esc>i
    inoremap " ""<Esc>i
    "inoremap { {<CR>}<Esc>O     	 "符号代表注释,这一行我注释了,因为有的时候需要{}中间自动回车空一行,有的时候不需要,我们暂时不需要

    set filetype=python

    au BufNewFile,BufRead *.py,*.pyw setf python
    set autoindent " same level indent
    set smartindent " next level indent
    set expandtab
    set tabstop=4
    set shiftwidth=4
    set softtabstop=4
    set nocompatible  
    set rtp+=~/.vim/bundle/vundle/  
    call vundle#rc()  

    " let Vundle manage Vundle  
    " required!  
    Bundle 'gmarik/vundle'  

    " The bundles you install will be listed here  
    Bundle 'scrooloose/nerdtree'  
    Bundle 'davidhalter/jedi-vim'  

    filetype plugin indent on  

    " The rest of your config follows here.  

    augroup vimrc_autocmds  
    autocmd!  
    " highlight characters past column 120  
    autocmd FileType python highlight Excess ctermbg=DarkGrey guibg=Black  
    autocmd FileType python match Excess /\%120v.*/  
    autocmd FileType python set nowrap  
    augroup END  
  
    " Prefer spaces to tabs  
    set tabstop=4  
    set shiftwidth=4  
    set expandtab  
    set nu!  
    map <F1> :ter<CR>
    map <F2> :call CompiletypeRunGcc()<CR>`
    func! CompiletypeRunGcc()
	exec "w"
	if &filetype == 'sh'
	   :!time bash %
	elseif &filetype == 'python'
	   :exec "!time python3.8 %"
	endif
    endfunc
    map <F3> :NERDTree<CR>
    map <F4> :vs<CR>
    map <F5> :sp<CR>
    set mouse=a
    :colorscheme murphy "这个自己选,可以不是murphy

经过一番东拼西凑,终于搞定了这个玩意儿
不容易不容易

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值