Live data from Hacker News

Using Vim as a Python IDE

liuchengxu.org

91–100 of 158 posts

Re: Using Vim as a Python IDE

#91
post #74

Yesterday I've downloaded VSCode and https://github.com/DonJayamanne/pythonVSCode (seriously, look at the GIFs in this repo!) for first time and I had autocompletion (with IntelliSense and documentation lookup), refactoring and code define jumping for Python code out of the box working within 10 minutes in a VirtualEnv. VSCode + one plugin (all opensource) and I had something similar to PyCharm and fast. (nothing aga…

I also have been switching over to VSCode for coding. The vim plugin is pretty decent. I still keep vim around for huge files though. I work daily with NASTRAN input and output files, routinely multiple 100 mb, sometimes multiple-gb. I edited a 10gb file earlier this week and vim didn't choke up too much. Best editor I've found so far for huge files.

Which VIM plugin are you using? I've tried them all, including the recommended one simply called 'vim', and they are all missing the most basic of features. Go-to-definition (Ctrl-]) was one missing for me just a few hours ago when I last tried it!

Re: Using Vim as a Python IDE

#92
post #29

Earlier quoted context omitted.

Also, comes with org-babel that can do similar stuff with literate programming.. Also not sure how people live without it.

One of the features that elevates org-babel is being able to work on the same data in multiple tools. It's not uncommon for me to start with data in a table, transform it with a bit of python or lisp, and feed the result into gnuplot.

If you could point to one simple example of this it works be awesome! I've used org-babel but in a very fragmented way. My sessions were separated from each other and I did not use multiple languages on the same data

Re: Using Vim as a Python IDE

#93
post #87

How do you jump to definition?

If you are editing files inside a package, you can generate a tags file for definitions inside that package.

More useful, IMHO, is the general solution of jumping to the definition that would be resolved by the python interpreter, regardless of location. For that, the key binding will depend on the plugin. For `jedi-vim`, you use `d` [0].

Incidentally, if you're new to using VIM as a python IDE, also note the value of `jedi-vim` providing Python docstrings via the standard VIM keybinding `K`. This is also mentioned in [0].

[0] https://github.com/davidhalter/jedi-vim#features

Re: Using Vim as a Python IDE

#94
post #76

Autocomplete with Conda has got no support - if anyone has any idea other than; https://github.com/cjrh/vim-conda

Well, if you genuinely want a braindead alternative to `vim-conda`, you're welcome to this brittle hack I use. (For my purposes, fast-and-dirty has been an efficient solution, but I don't actually recommend this to anyone.)

Add it to your `ftplugin/python.vim`. Requires you to have activated the Conda environment before opening the Python file, uses hard-coded Python versions, doesn't work with multiple environments, doesn't bother with `os.path.join` so no Windows compatibility, etc etc. Like I said: a hack.

  " Cheap trick to use the Conda environment with omnicompletion
  python3 
edit: mentioned `os.path.join` to warn Windows users and fixed in-place bugfix.

Re: Using Vim as a Python IDE

#95
I want to give a shout out to spacemacs.org which let's you do so many of these things and really does feel like the best of Emacs and Vim together. I will say I am a new convert so I can't comment so much in the plugin infrastructure but raw coding is really good and it's very configurable like emacs but without all of emacs overhead

Re: Using Vim as a Python IDE

#96

Emacs comes configured with a command called "send-region-to-shell" that will take the current region and send it to a python interpreter. It makes for a great development experience that I haven't seen replicated with other tools and I'm not sure why there's not a bigger interest in it.

> Emacs comes configured with a command called "send-region-to-shell"

The superior solution you are looking for is the package called elpy.

It provides this, linting via flycheck, contextual auto-completion via company-mode, etc etc.

I wouldn't know how to survive without it. It's almost a full IDE in itself.

Re: Using Vim as a Python IDE

#97
post #74

Yesterday I've downloaded VSCode and https://github.com/DonJayamanne/pythonVSCode (seriously, look at the GIFs in this repo!) for first time and I had autocompletion (with IntelliSense and documentation lookup), refactoring and code define jumping for Python code out of the box working within 10 minutes in a VirtualEnv. VSCode + one plugin (all opensource) and I had something similar to PyCharm and fast. (nothing aga…

I also have been switching over to VSCode for coding. The vim plugin is pretty decent. I still keep vim around for huge files though. I work daily with NASTRAN input and output files, routinely multiple 100 mb, sometimes multiple-gb. I edited a 10gb file earlier this week and vim didn't choke up too much. Best editor I've found so far for huge files.

I have vscodevim plugin, currently 0.5.2 and it's decent, it's been making progress, yet still it has little things that definitely detract from the experience, like motion keystrokes do not take the key auto-repeat. Actually it works moving by block ({}) and line (+-) but not with character (i,j,k,l) or word motions (wW,bB,eE) or next/previous occurrence of search (nN). Annoying. At least now they've fixed the issue where I had to re-enter a search term when switching buffers. So there's progress, and it will eventually be just as good.

Re: Using Vim as a Python IDE

#98
post #52

Earlier quoted context omitted.

Well this is your use case. I use Linux every day but I never touch python code directly on remote systems (it's getting automatically or manually deployed). All my python code lives in virtualenv locally here. But I understand when people work for many projects they maybe want to encapsulate it more (vagrant etc.).

Of course, use cases are different. In my case I usually deploy either automatically or manually, but in those rare cases when you can't replicate bug locally there is nothing better than vi. But of course, to each his own.

Debugging directly on the production system?

Yeah, nobody does that. Well, nobody who has any kind of serious operation going on.

If you can't replicate a bug outside a production environment you have a serious deficit in the devops department.

You should be able to stage a machine with a copy of the production DB/data and the same reproducible package(code) that currently runs on your production systems.

Everything else is just an accident waiting to happen.

Re: Using Vim as a Python IDE

#99

Hadn't heard of w0rp/ale, but it looks like an improvement over Neomake. I feel like I've done a pretty good job at enabling a lot of features with only ~200LOC vimrc[0]. I also avoid dependencies that need to be compiled or depend on a scripting language installed to the system. My .zshrc these days even parallels my vimrc style[1]. [0]: https://github.com/jzelinskie/dotfiles/blob/master/.vimrc [1]: https://github.c…

Same here, I'd never heard of it. I switched over to check it out, and am very pleased with how much more responsive it is than neomake. It's marking things while I'm still in insert mode, and not waiting till I save the file, quite useful. It's probably going to stick around and be my new go too!

Even though I write ruby and javascript all day, I still like to go and read how others are using vim. I usually walk away with a keybinding or plugin that makes my life better.

Re: Using Vim as a Python IDE

#100

Emacs comes configured with a command called "send-region-to-shell" that will take the current region and send it to a python interpreter. It makes for a great development experience that I haven't seen replicated with other tools and I'm not sure why there's not a bigger interest in it.

I did this with a tslime plugin from vim for several years. I used it extensively for javascript, sql, python, and clojure. After awhile, I stopped fighting and switched to spacemacs so I wouldn't have to both do my dayjob and maintain an IDE.

I have a nice 'generic-eval' operator in evil that lets me select via motions and eval the result. This is the best experience I've found so far. Documented here: https://gist.github.com/ad2b435bfdf2ec5f0b4d57aa8ea40df6

Post reply on HN