为Python设置Vim [英] Setting up Vim for Python
问题描述
我真的很喜欢Python的Emacs编辑器,因为它是智能tabbing例如,如果我有这样的东西
def foo ():
如果bar:
blah
[b] eep
并且我按下光标(在b上的哔哔声)的选项卡,它不会插入一个新的选项卡导致语法错误,但它会切换通过可能的哔哔声可能的级别。
一般来说,vim是一个非常强大的强>编辑器(宏扩展这个,但我们现在将忽略)。这是因为vim是ed的顶层的一个薄层,ed不是一个使用正则表达式的行编辑器。 Emacs具有建立在ELisp之上的优势;使它能够轻松解析复杂的语法,并执行缩进技巧,例如你上面分享的。
说实话,我从来没有深入到深度的emacs,因为它只是令人愉快冥想在我的vim洞穴。
p>对于初学者,我强烈建议您安装现成的 Janus插件(fwiw,来自星际迷航剧集特色Janus Vim的名字)。如果你想要一个快捷的vim IDE,它是你最好的爆炸为你的。
我从来没有使用过,但我已经看到别人快乐地使用它
p>否则,自己做一些探索!如果您想查看vim插件的全域,我强烈建议您安装 vim病原。 p>
这是一个包管理器。安装后,您可以将 git clone
包放到您的〜/ .vim / bundle
目录中,安装。
您可以从GitHub页面运行以下脚本来安装病原体:
mkdir -p〜/ .vim / autoload〜/ .vim / bundle; \
curl -so〜/ .vim / Autoload / pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim
有用的链接
vim我找到并喜欢:
-
将Vim转换为现代Python IDE - Vim As Python IDE
- OS X和Python (特定于osx)
- 学习Vimscript The Hard Way (如果你想学习vimscript,那么很棒的书)
I really like the Emacs editor for Python because of it's smart tabbing for instance if I have something like this
def foo():
if bar:
blah
[b]eep
and I press tab on the cursor (which is on the b of beep), it will not insert a new tab causing a syntax error but it would toggle through the possible levels that beep can be on. Is there anyway of getting this effect on Vim?
In general, vim is a very powerful regular language editor (macros extend this but we'll ignore that for now). This is because vim's a thin layer on top of ed, and ed isn't much more than a line editor that speaks regex. Emacs has the advantage of being built on top of ELisp; lending it the ability to easily parse complex grammars and perform indentation tricks like the one you shared above.
To be honest, I've never been able to dive into the depths of emacs because it is simply delightful meditating within my vim cave. With that said, let's jump in.
Getting Started
Janus
For beginners, I highly recommend installing the readymade Janus plugin (fwiw, the name hails from a Star Trek episode featuring Janus Vim). If you want a quick shortcut to a vim IDE it's your best bang for your buck.
I've never used it much, but I've seen others use it happily and my current setup is borrowed heavily from an old Janus build.
Vim Pathogen
Otherwise, do some exploring on your own! I'd highly recommend installing vim pathogen if you want to see the universe of vim plugins.
It's a package manager of sorts. Once you install it, you can git clone
packages to your ~/.vim/bundle
directory and they're auto-installed. No more plugin installation, maintenance, or uninstall headaches!
You can run the following script from the GitHub page to install pathogen:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -so ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim
Helpful Links
Here are some links on extending vim I've found and enjoyed:
Turning Vim Into A Modern Python IDE- Vim As Python IDE
- OS X And Python (osx specific)
- Learn Vimscript The Hard Way (great book if you want to learn vimscript)
这篇关于为Python设置Vim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!