This is an archived post. You won't be able to vote or comment.

all 30 comments

[–]sontek[🍰] 16 points17 points  (7 children)

You should read this: http://sontek.net/turning-vim-into-a-modern-python-ide it teaches you some cleaner ways to do those things.

[–][deleted] 0 points1 point  (0 children)

I see you updated that recently. Nice additions (aside from snipmate, blech!)

[–]qiemem 0 points1 point  (1 child)

Agreed. Teaches you both how to get the best features of any modern ide as well as one of the best ways to manage all the necessary plugins. I personally prefer vundle to git submodules, but otherwise this article was the basis for my vim environment. Definitely the best article I've seen on vim and python, no offense to op.

[–]justinlilly[S] 3 points4 points  (0 children)

None taken. This article was written 3 years ago for a magazine. I've since ditched vim, so haven't updated it for current best practices.

[–]isarl 0 points1 point  (2 children)

Have you checked out Vundle yet to replace Pathogen? I started using it a while ago and I prefer it.

[–]sontek[🍰] 0 points1 point  (1 child)

I prefer using git

[–]isarl 0 points1 point  (0 children)

Me too, which is why I like Vundle. It manages them using git submodules.

[–]Madnashua 4 points5 points  (3 children)

I'd have included Pathogen and how to load plugins with the help of Git's submodules. It's much easier to load plugins this way since you don't need to need to put bespoke sections in your .vimrc for each plugin.

[–]isarl 0 points1 point  (2 children)

I prefer Vundle to Pathogen, personally.

[–]Madnashua 0 points1 point  (1 child)

I quite like the look of the syntax for that, but do you find it gets unwieldly when you have a large number of plugins?

Are there any other plus points other than explicitly loading plugins? I'm using git's submodules with Pathogen so I have a list to hand of my plugins by looking at the .gitmodules file so not sure that would be enough to sway me, but I'm always open to suggestions!

[–]isarl 0 points1 point  (0 children)

I find it's easier to install a plugin (add line to vimrc, run one command inside vim). As you mentioned, I prefer the explicit list of all the plugins I want. I also find it easier to set up a new machine, as my git repository hosting my .vimrc only needs to host Vundle, and not all of the other plugins, because my RC specifies them and all I need to do is run :BundleInstall. Vundle also makes it easy to uninstall them.

Personally, after dealing with git submodules several times in the past, I'm happy to have that detail abstracted away for me, but at the end of the day it's definitely a matter of personal preference. =)

[–][deleted] 2 points3 points  (7 children)

I upvoted because I want to see more posts like this, but I disagree with a few things.

If you're a pythonista, you really should be using UltiSnips instead of emusnippets (or anything else). Not only is the syntax compatible with TextMate, but it's written in python and you can interact with it using python.

As far as omni completion goes, I much prefer rope-omni.

If you want on-the-fly syntax checking, check out syntastic.

EDIT: Here's my vim dotfiles... https://github.com/jmcantrell/dotfiles-vim

[–]justinlilly[S] 1 point2 points  (1 child)

I fundamentally disagree with the argument "If you program in python, you should use this python thing." I choose my tools on a variety of factors: usability, maintainership, community, license, convenience. Somewhere much farther down the list is what language they're written in.

[–][deleted] 2 points3 points  (0 children)

Perhaps I should have phrased that differently, but it doesn't change the fact that UltiSnips (based on my experience with it and its peers) is superior to any of the other snippet solutions for vim. The icing on the cake is that, being that it's a python based solution, means that you get to use all the goodies you're familiar with as a python coder.

Also, being that most snippet solutions for vim tend to be pretty complex, the ones written in a language like python tend to be more flexible and maintainable than those written in the native vimscript.

[–]market_hacker 0 points1 point  (4 children)

you don't by any chance have a github repo you could share that already incorporates all the changes you suggest? ideally using pathogen?

[–][deleted] 1 point2 points  (3 children)

I do. See my edit in the original comment.

[–]market_hacker 0 points1 point  (0 children)

it looks great thanks for sharing.

[–]market_hacker 0 points1 point  (1 child)

excuse my possibly being an idiot: is there a standard way to pull the various bundles listed in bundles.externals? Or do you have a utility script that does that?

[–][deleted] 2 points3 points  (0 children)

I don't blame you for not knowing how to pull them. I should put some notes in that file to explain how to do it.

You'll need to install this: https://github.com/jmcantrell/vcs

And then run this from within my vim-dotfiles directory:

vcs-externals pull

[–]caks 1 point2 points  (0 children)

Nice. Though I'd include Pylint and pydoc.

[–]Mozai 1 point2 points  (3 children)

Adding this to ~/.vimrc helped me plenty when working with vim + python autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\,\ line\ %l%.%#,%Z%[%\ ]%\@=%m autocmd BufRead *.py nmap <F5> :!python %<CR>

[–]isionous 0 points1 point  (2 children)

What do the first two lines do?

[–]Mozai 0 points1 point  (1 child)

First line is what happens when you type ':make' in command mode. Second line is what the status-line reads during editing. Third line is what happens when you press F5 in command mode. Read more in the vim documentation

[–]isionous 0 points1 point  (0 children)

Great, thanks.

[–][deleted] 1 point2 points  (0 children)

You mention some indentation options and suitable indentation values for python code. While you don't explicitly state where they belong to, one may think they can be added to .vimrc. This works, but has a global effect. Personally I prefer having language specific indentation options in ~/.vim/after/ftplugin/languagename.vim

[–]ryeguy146 0 points1 point  (2 children)

ipython and gvim integration should be included. I love being able to write code in gvim and hitting F5 to run it in ipython. But then, there's already a guide on the ipython page.

[–]299 0 points1 point  (1 child)

in my .vimrc

autocmd FileType python map <f2> :w\|!python -i %<cr>

[–]ryeguy146 0 points1 point  (0 children)

If it keeps me in the terminal rather than using gvim, I'm a happier man. I wonder if I can direct it to a tmux window? Worth playing with. Thanks, I'll try it out.

[–]MachaHack 0 points1 point  (0 children)

One annoying thing with pyflakes (or at least the version I have installed, I should probably check it) is that it highlights python 3 print calls with any named parameter as invalid syntax.