14 ms·
Using Vim as a Python IDE
- empath75 10y agoI keep seeing tmux mentioned recently. Can someone eli5 what it does and why it's useful?
- gambogi 10y agoA terminal mux. Mux is short for multiplexer, which chooses between different inputs. It is a tool for running keeping multiple terminal sessions open at the same time. These sessions can be attached and detached from, which is often helpful when working on a remote machine you may want to access from different work stations. Screen is a similar program.
- entelechy0 10y agoLook up gnu-screen
- scardine 10y agotmux is a terminal multiplexer - if you have ever used the `screen` command you already know what it is. I use a macbook pro with iterm2, and I prefer to use a terminal multiplexer instead of tabs or the native screen split of iterm2. If you ssh remote boxes a lot, it is very useful because you will not lose your session in case of an occasional disconnection.
- vlunkr 10y agoIterm2 also has a nice tmux integration. You can connect to a session but use native tabs and panes. It even works on remote servers over ssh. You just add a '-CC' arg. (You may also have to enable it in the prefs, don't remember for sure)
- scardine 10y agoIn fact I use byobu instead of plain tmux.
- namepros 10y agoI've never been able to get iTerm2's tmux integration to work well enough to warrant the bother.
- rajathagasthya 10y agoThis is what I usually do to connect to a remote server and enter a tmux session: ssh hostname -t "tmux -CC attach || tmux -CC" Of course, I picked this up from an HN comment :)
- bitwize 10y agoiTerm2 has tmux integration. No need to give up native tabs!
- pca2 10y agoIt also allows you to "split" your terminal into multiple tabs, panes and windows, which makes it easy to hop back and forth between sessions in multiple environments. As others have said though the killer feature really is that you can run it on a remote machine and attach and detach at will.
- sidmitra 10y agoMost of the other comments mention that you can split your screen into tabs and panes. But by far the most important feature of gnu-screen or tmux is the ability to have a shell session running even when you're not logged in. So you can use tmux to start a shell session and run a script(say a command line IRC client) and leave it running. Next you'll just 'detach' from your tmux session and can logout. Your irc client or any number of scripts you started from your tmux session will still be running. You can relogin later and 'attach' to that session and you'll continue where you left off. Infact you can start a tmux session on the server in the office, detach/logout and go home and attach to the same exact screen from home, that you left in the office. Not to mention you can share your command line shell session/screen with other people!!
- closed 10y agothis x 1000 tl;dr, use tmux if you ssh into places and hate restarting after losing your connection.
- wutbrodo 10y agoI figured out running screen at the beginning of pretty much every ssh session probably freshman year of college, and it kind of shocks me to hear that people don't regularly do that.
- wsha 10y agoThis is the best feature of tmux. It's worth pointing out here though (in a post about making the terminal act like an IDE), that you can split the terminal into two panes so you can have an editor and a REPL open at the same time similar to many IDE's. There are even some projects that make it easy to pass code between the editor and the REPL in the other pane, though I have never gotten them to work very well.
- groovy2shoes 10y agovim (and emacs) can do that without the need for a terminal multiplexer (though in vim you need to use a "plugin" for it, or, at least, you used to, and I'm sure the new async functionality in vim 8 has improved the experience quite a bit)
- mod 10y agoMaybe my favorite feature of tmux, which I don't see mentioned here, is that I can configure it to start up in a certain way. Using tmuxinator, I might set up a config for a rails project, for instance. That way when I start tmux I get a vim editor in one window, a bash prompt in the next (for git), a rails server in the third, tests in the fourth, maybe another process in the 5th like sidekiq or something if required. Note, these (tmux-)windows all live inside of one terminal window. So once you spend about 2 minutes writing that config, you can always start up your environment with tmuxinator start project-name and a few seconds later you're good to go.
- a3n 10y agotmux is like structured LSD, opening terminals to the Universe in unlimited instances and recursions of Sessions and Windows and Panes, and Windows and Panes, Panes, Panes ... Panes ... Multiple realities of Sessions can be started, persisted, detached, reattached, and can exist on your local laptop, another machine on your LAN, or school or corporate network, or the Space Station or Mars, all spanned by your one mind and The One Mind. Man. https://linux.die.net/man/1/tmux https://linux.die.net/man/1/tmux Or if you're not into the whole brevity thing: https://linux.die.net/man/1/tmux https://linux.die.net/man/1/tmux Try it with a friend the first time.
- drewjaja 10y agoThe most useful feature of tmux for me is the ability to switch between different projects effortlessly. Within a session i would have multiple windows, one for each project. Within each window i would have one pane for editing code and another pane running a development server. If you've used macos multi desktops you can think of a session as a macos machine, a window as a desktop, and a pane as a application window. And everything is persistent so you can detach from the session and reattach and all your windows and panes will be there as you left it.
- flukus 10y agoApart from sessions, you can do that from within vim itself.
- adrianN 10y agohttps://news.ycombinator.com/item?id=12902887 https://news.ycombinator.com/item?id=12902887
- sametmax 10y agoThe more you use the terminal to do complicated stuff, such as managing screens, the more you actually offload part of the work to your brain. You have to remember mapping, positions, transitions, and think every time you interact with them. This cognitive load takes CPU cycles from your brain instead of your machine, which is then not available for your current task, and of course it tires you more on the long run That's why, while I use VIM when I have to, I much prefer the technology to handle automatically whatever it can. Like maintaining states, making them obvious and offload any fruitless decision making.
- scardine 10y agoI would love to download a config file with a curated list of plugins that turns vim into a good Python IDE.
- liuchengxu 10y agohttps://github.com/liuchengxu/space-vim https://github.com/liuchengxu/space-vim Here is the vim configuration.
- gravypod 10y agoLet me augment that with this: I would love to donate to a project that uses ${INSERT_TERMINAL_TEXT_EDITOR} and turns it into a general IDE. I'm talking the full shebang. * Autocomplete/Autoimporting (Static Analysis backed by compiler output) * Formatting * Linting * Fast or able to run over a slow SSH connection. * Default error resolutions (if test() throws an exception generate a try { }) * Global refactoring * The idea of a project (Creating, building, export/importing, libraries, dependencies) * Automatically generated & maintained building system at the click of a run button * Documentation at a single click or on hover if possible * Integrated console for running a project * File and source manager that should be easy to use * Binding profiles for Eclipse, NetBeans, JetBrains, VS20XX, ReSharper Optionally these would be nice: * Formal Method Verification? * Coloring/styling of the entire TUI * Simple to interact with menus * Rust, Go, JavaScript (Browser & Node), Java, Scala, C, C++, PHP, Python support * Pluggable language support that allows the plugin to provide static analysis & compiler data If that can all be provided that could easily sell for $25 to $50 per user and I'd be happy, happy!, to pay every last dollar of it. It'll never happen. The world will never be that kind to software developers.
- Ar-Curunir 10y agoThere's been "distros" of popular editors like Emacs and Vim aiming to provide this functionality. Spacemacs is one, and there's another one for Vim.
- tebeka 10y agoI heard good things about http://vim.spf13.com/ http://vim.spf13.com/
- therealmarv 10y agoYesterday I've downloaded VSCode and https://github.com/DonJayamanne/pythonVSCode 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 against vim, just want to mention how impressed I was)
- poisonarena 10y agogod help me escape pycharm, i only got 4gb of ram
- santaclaus 10y ago> i only got 4gb of ram Well, for all of their benefits Electron apps in general have some hiccups on resource constrained systems.
- Godel_unicode 10y agoNot sure what Electron has to do with pycharm, as with most (all?) other JetBrains software it runs on the jre. Edit: realized you're probably talking about vscode, which is an electron app
- throwawayish 10y agoBoth VSCode and Atom are memory intensive as well. That being said I've used PyCharm on a system with 2 GB memory before and that does work okay, you just need to make sure that no other memory-hungry apps run at the same time (browser, email, multimedia) and that the system itself doesn't use too much memory.
- sidusknight 10y agoHow does this compare to something like sublime + anaconda?
- wry_discontent 10y agoEmacs 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.
- gogoengie 10y agohttps://github.com/jpalardy/vim-slime https://github.com/jpalardy/vim-slime https://github.com/epeli/slimux https://github.com/epeli/slimux
- duck2 10y agoThat looks very doable in acme[0]. [0]: https://research.swtch.com/acme https://research.swtch.com/acme
- base698 10y agoAlso, comes with org-babel that can do similar stuff with literate programming.. Also not sure how people live without it.
- andreareina 10y agoOne 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.
- kovek 10y agoIf 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
- andreareina 10y ago
- superquest 10y agoNice post. I also really like you "space-vim" project. Another similarly named project — "SpaceVim" http://spacevim.org/ http://spacevim.org/ — was posted recently. "SpaceVim" was really upsetting because it missed so many of the important ideas of Spacemacs, such as pneumonic keybindings. "SpaceVim" is a garden variety vim distribution coopting the "Spacemacs" name, but you stayed true to the "Spacemacs" principles. Nice work!
- liuchengxu 10y agoI'm glad you like it. That's because I'm both a vimmer and a spacemacs user -_-.
- matthewbauer 10y agoThis threw me for a second but its "mnemonic" not "pneumonic".
- deleted 10y ago[deleted]
- StavrosK 10y agoUntil I read your comment I was trying to figure out why they called them air-propelled keybindings, not finding any obvious analogies...
- wyclif 10y agoA Chinese programmer emailed me because I starred the linked SpaceVim repo. I guess there's some confusion about all the forks of this project.
- superquest 10y agoWow the same thing just happened to me to! The maintainer of the competing "SpaceVim" project I mentioned just opened an GitHub issue on my personal dotfiles repo to spam me with his project: https://github.com/superquest/dotfiles/issues/1 https://github.com/superquest/dotfiles/issues/1 Bizarre.
- MooMooMilkParty 10y agoThe one thing I'd love to see, as a vim user and a scientist, is something like Matlab/RStudio/Spyder where you can explore variables that exist within a session. Maybe it could hook up to an ipython session and you could display it in a separate terminal and send commands with vim-slime to be updated in real time. For the most part, when I need this, I revert to Rodeo (since it has vim bindings like RStudio's), but if I could ditch it that would be amazing. Nothing against Rodeo or other editors, but vim habits are hard to break.
- javitury 10y agoI know you are looking for a python plugin. But since you mention R, have you tried nvim-R? Works for vim 8+ https://github.com/jalvesaq/Nvim-R https://github.com/jalvesaq/Nvim-R
- ice109 10y agopycharm let's you do this! this is the only thing I missed from MATLAB. you can set a breakpoint in a script and open up the debug console and see all the live variables and run code. it works perfectly and you get Python + pycharm. I'm spoiled now and anticipate having trouble moving to another language.
- c06n 10y agoIt's been a while that I have used it, but I used to do that in Matlab all the time. The shortcut in the IDE was F9, I think.
- jzelinskie 10y agoHadn'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 https://github.com/jzelinskie/dotfiles/blob/master/.vimrc [1]: https://github.com/jzelinskie/dotfiles/blob/master/.zshrc https://github.com/jzelinskie/dotfiles/blob/master/.zshrc
- thatmiddleway 10y agoSame 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.
- agounaris 10y agoSeriously people this is 2017! We have the technology. Learn vi in order to have the same editing experience everywhere but honestly when it comes to IDEs, there are just really good software packages out there with 0 configuration hassle.
- ageofwant 10y agoYou imply that vim is somehow technological inferior to some other tool. I take issue with that. I don't use vim because I have to or some silly 'vim everywhere' argument. I use it because it is a demonstrably superior text editing appliance. Every so often when vim irritates me I try out PyCharm or vm-whatsit, and while IDE's do have better viz for some use cases, the actual act of manipulating code in-buffer never comes close to speaking vim. And I always add the vim plugin, without them the tool would be of no use to me whatsoever. I hope someday some tool will eclipse (no) vim, but that's simply not the case in 2017.
- falcolas 10y agoI'm in the same boat. Local development only, my terminal is still my IDE. Other editing tools I've attempted and jumped back out of: PyCharm - No good vim emulation for editing Spacemacs - Soft locks, Ctrl-] doesn't follow the same word boundaries as Meta-. (which matches Vim's implementation) Sublime Text - Closest fit (enough that I own a personal license), but again, the vim emulation is pretty bad. Atom - Slow. Even at its fastest, it's noticeably slower than Vim VSCode - Slow (though faster than Atom), no good vim emulation. Yes, most of my criticisms form around the lack of good vim emulation - my muscle memory is very well established. I've just yet to find a good, responsive, and comfortable editing scheme from a non-Vim editor.
- WildUtah 10y agoI'm trying Neovim and it's the only editor I've ever tried that I like as much as Vim. Every other substitute has been inadequate.
- TallGuyShort 10y ago
- vgy7ujm 10y agoLove vim, not so sure about that snake..
- theRhino 10y agothis look s ok but i don't see a section on pdb integration - i'd say thats key. I'm still looking for a sensible description of how to develop python in emacs. I'm amazed that there doesn't seem to be a de facto way to do it..
- machbio 10y agoAutocomplete with Conda has got no support - if anyone has any idea other than; https://github.com/cjrh/vim-conda https://github.com/cjrh/vim-conda
- gogoengie 10y agoWell, 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 << EOF import os import sys cenv = os.environ.get('CONDA_PREFIX') if cenv is not None: # Taken from `sys.path` as reported by ipython sys.path.insert(0, cenv + '/lib/python3.5/site-packages') sys.path.insert(0, cenv + '/lib/python3.5/lib-dynload') sys.path.insert(0, cenv + '/lib/python3.5/plat-linux') sys.path.insert(0, cenv + '/lib/python3.5') sys.path.insert(0, cenv + '/lib/python35.zip') sys.path.insert(0, cenv + '/bin') EOF set omnifunc=python3complete#Complete edit: mentioned `os.path.join` to warn Windows users and fixed in-place bugfix.
- tamatsyk 10y agoI have been using vim as my primary IDE for small projects for more than a year till previous month. Everything was fine, even optimizing slow plugins was OK for me. The best plugin I used was a YCM, the best autocomplete I've seen in console world, and there were so many problems with it. Finally I gave up and moved to NeoVim and have no issues with my vim anymore. Maybe later I will give another try to spacevim or emacs. Maybe. So far, keeping my fingers safe :D
- IgorPartola 10y agoI would love to replace Syntastic with ale, but (1) is there a way to have it just highlight the line with the error instead of using the gutter? And (2) is there a way to get it to use pyflakes instead? pylint is a little too aggressive: it complains about modules it can't import which is by design in my working environment.
- yes_or_gnome 10y agoInstall flake8, there's support for mypy, flake8, and pylint. I can't answer the other, but you could always file a feature request.
- mezuzza 10y agoAlternatively, add the following to your `~/.pylintrc`. Granted pylint just stops checking those particular modules, but it's better than nothing. [TYPECHECK] ignored-modules = ssl,pyodbc
- Graziano_M 10y ago`let g:ale_linters = { 'python': ['flake8'], }`
- Siecje 10y agoHow do you jump to definition?
- gogoengie 10y agoIf 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 `<leader>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 https://github.com/davidhalter/jedi-vim#features
- no_wizard 10y agoI 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
- Synroc 10y agodid you have experience beforehand in using emacs? I've been using spacemacs for a couple of weeks, but I'm having trouble getting past the most basic usage, and partially it's because I feel like I don't have much experience with emacs.
- no_wizard 10y agoI did not in any real sense. I did the tutorial and chose the sane defaults recommended (so called Evil Mode) which gives you some great controls and a nice tutorial you can walk through if you type :tutor at the main screen. I admit I have never used Vim or Emacs but the tutorial was enough to do movement and I also read this wonderful documentation as well: First this here which gives a wonderful overview of the whole philosophy behind SpaceMacs: http://spacemacs.org/doc/DOCUMENTATION http://spacemacs.org/doc/DOCUMENTATION Then I took a look at this just to get some better idea of how to do certain things with the layers since it's very dependent on a layering system: http://spacemacs.org/doc/LAYERS.html http://spacemacs.org/doc/LAYERS.html And for good measure since Evil mode emulates Vim I thought it might be nice to see what this had to say: http://spacemacs.org/doc/VIMUSERS.html http://spacemacs.org/doc/VIMUSERS.html It took me like a week to be efficient but now I'm flying so much faster than I was with VS Code or Atom. I still use Sublimr Text for some things because I like it but this is a great editor and has a lot of potential and is extremely extensible with Emacs lisp and I believe they already have a way to bridge in Vim plugins too
- xs 10y agoCan vim do multi-cursor editing? Like how sublime text can?
- shriek 10y agoIt can but it's not robust as sublime's multi-cursor editing. https://github.com/terryma/vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors
- fattymagoo 10y ago100010000000100001010100101000001001001010100101000010010100001010101010010101010010011100010101110010101010101010101010010101010101010101010101010101001001010019010101010010100101010101101000101010101010101000001110+
- fattymagoo 10y agohi
- qwexvf 10y agocould you share the dotfiles please?
- wsdjeg 10y agohttps://github.com/SpaceVim/SpaceVim https://github.com/SpaceVim/SpaceVim
- superquest 10y agodude stop spamming your project! ^^ he's pushing a completely separate project that competes with one of OP's projects.
- liuchengxu 10y agoBuddy, I think this is really disrespectful, not only for me but for the others.
- liuchengxu 10y agoHere is the true vim configuration shown in the post: https://github.com/liuchengxu/space-vim https://github.com/liuchengxu/space-vim
- wsdjeg 10y agoIf you are interested, maybe you can have a try with https://spacevim.org https://spacevim.org
- liuchengxu 10y agoPlease stop do this.