Vim與Python的天作之合macOS配置

首先,打開電腦終端並執行以下命令安裝Homebrew:

<code>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"/<code>

更多關於Homebrew, 大家可以訪問官網:https://brew.sh/

安裝Vim:

<code>brew install vim/<code>

安裝Vim插件:Vundle

<code>git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim/<code>

如果您的電腦上還沒安裝git就先執行以下命令安裝:

<code>brew install git/<code>

創建.vimrc文件於根目錄

<code>touch ~/.vimrc/<code>

將以下這些代碼複製並粘貼至剛剛創建的.vimrc文件中的最頂部

<code>set nocompatible              " required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)

" ...

" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required/<code>

然後運行:

<code>:PluginInstall/<code>

之後您就可以以此類推安裝各種各樣的插件了,

此文不能將所有插件一一列出,但可推薦對於Python開發非常有用的一些。

分屏佈局:

橫屏命令:

<code>:sp /<code>
Vim與Python的天作之合macOS配置

豎屏命令:

<code>:vs /<code>
Vim與Python的天作之合macOS配置

可設置分屏為向下或向右分:

<code>set splitbelow
set splitright/<code>

代碼伸縮功能:(詳情:https://vim.fandom.com/wiki/Folding)

<code>set foldmethod=indent
set foldlevel=99/<code>

用空格鍵快速執行伸縮命令:

<code>" Enable folding with the spacebar
nnoremap <space> za/<space>/<code>

準確伸縮插件:

<code>Plugin 'tmhedberg/SimpylFold'/<code>

添加之後執行安裝命令:

<code>:PluginInstall/<code>

添加可見代碼伸縮:

<code>let g:SimpylFold_docstring_preview=1/<code>

支持UTF-8

<code>set encoding=utf-8/<code>

PEP 8規範查看:

<code>Plugin 'nvie/vim-flake8'/<code>

美化代碼:

<code>let python_highlight_all=1
syntax on/<code>
<code>Plugin 'morhetz/gruvbox'/<code>

文件瀏覽:

<code>Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
let NERDTreeIgnore=['\\.pyc$', '\\~$'] "ignore files in NERDTree/<code>

超級搜索:

<code>Plugin 'kien/ctrlp.vim'/<code>

Git集成

<code>Plugin 'tpope/vim-fugitive'/<code>

狀態條

<code>Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}/<code>

如果您嫌煩,直接訪問以下地址粘貼複製設置即可:

https://github.com/wangold/vim-config/blob/master/vimrc


分享到:


相關文章: