Hacker News new | past | comments | ask | show | jobs | submit login
Vim & Python: Making yourself at home (justinlilly.com)
184 points by abrahms on July 29, 2011 | hide | past | favorite | 29 comments



Please, save yourself the hassel and use Pathogen for all your vim plugin needs. Otherwise there's some nice tips in this article.


Actually, I found vundle (https://github.com/gmarik/vundle) to be slightly easier to use.


That's interesting, but it's a very different approach to Pathogen, and it's very much a matter of taste IMHO. I prefer to use git submodules directly or through a general-purpose scripting language and just have the vim component load my plugins.


Exactly. I use homesick to version and sync all the config files in my home directory across machines (linux and OSX alike), and git submodules already solve the problem for me.


My .vim folder would be a gigantic mess without Pathogen. I recommend using Tammer Saleh's update_bundles script ( http://tammersaleh.com/posts/the-modern-vim-config-with-path... ) to keep your vim plugins up to date.


I hadn't seen that one before so I came up with a similar script that updates both git and mercurial repositories: https://bitbucket.org/tednaleid/vimrc/src/tip/install.sh

Tammer's has some nice things in it that I might crib, thanks for the link


The author switched to Emacs. https://twitter.com/#!/justinlilly/status/96630245226061824

But yeah, as a vim user I agree. Pathogen helps a lot.


I wish HN had a Save button, so I could remember to come back to this later, and experiment with the parts I didn't already know.


It's a little weird (to me at least), but upvoting stories in HN is considered 'saving' them. You can view all your saved stories from your profile page under the link 'saved stories'.

You can also just go to: http://news.ycombinator.com/saved?id=jholman


There is also this to download those 'saved' links:

https://github.com/bsandrow/hn-profile


Reminder Bear, created by a fellow HNer, works pretty well for this - http://app.reminderbear.com/



if only there were a way to save and share urls using some sort of online service.


Bookmark the page in your browser?


I use instapaper for stuff like that.


Does anyone else use code folding plugins for vim? If you have something good for this, please share, since all the popular plugins are pretty buggy (they fold functions withing functions, and sometimes just white space).


I've just been using vim's built in folding with indentation as the fold method. Thus far I have complaints; it seems to work as I want it.


http://paste.pocoo.org/show/449029/

As mentioned in the paste:

Please note that this is hacked Python SimpleFold. I don't know how much of the original plugin the code share (as I hacked it loooong ago). Do remember that it doesn't always work (but always do with my company's coding conventiens; hear I have no intent to make it work for others). Also, there is probably some useless crap laying around.

Edit: Judging by my English, I'm really tired. I leave it as-is for posterity and because it's the way it is in the paste.


Just fold by indent or syntax, if your code isn't already indented right, you're doing it wrong :-)


Some people don't want if-else, while or for blocks folded, which will happen if you just fold on indent with considering syntax.



I am experiencing weird glitch at your site: http://cl.ly/8v2D

Using Chrome 14.0.835.8 dev, Mac OS X 10.7


no love for my pydoc.vim? https://github.com/fs111/pydoc.vim


Nope, no love =(


One thing i miss in languages like python that don't enclose blocks in {} is the convenience of using % to find the matching beginning/end of the block.


I use "vii" in normal mode to do that. It basically selects the block.

http://vim.wikia.com/wiki/Indent_text_object


That, and the lack of constant constants (class workarounds don't do it for me) are the only two "complaints" for me.

On the whole I really like significant white space (despite my suspicions before taking up the language). With a brace-blocked language like C, indentation can fool you into thinking there's a block when there really isn't.

This is very unlikely to happen in Python. A section of code that looks like a block due to indentation is virtually certain to be a single coherent block. I love that.


I haven't tried it in Python, but it's worth checking out matchit.

http://www.vim.org/scripts/script.php?script_id=39

matchit generally seems to do a good job at identifying beginning/end pairs in a variety of languages.


In my years of experience, I've found that huge ass blocks of code where % is useful in finding the beginning/end of a block are usually in need of massive amounts of refactoring.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: