Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Build an IDE with tmux and vim (alexyoung.org)
91 points by ahalan on March 18, 2012 | hide | past | favorite | 44 comments


One nit: "considering the loss of the convenience of mouse input"

You can get full mouse support in tmux/vim.

I recently read the tmux book by the pragmatic programmers and highly recommend it: http://pragprog.com/book/bhtmux/tmux

It's short, well written and contains lots of essential configuration tips to get not only mouse support but also system copy/paste on a mac. Here's my tmux.conf if you're curious: https://github.com/briandoll/dotfiles/blob/master/tmux.conf


I can second the recommendation for Brian Hogan's tmux book. I have a feeling it will become the tmux book to get for some time. It's short enough that you can get through it without a major investment, and long enough that covers everything (and more) to become productive with tmux.


Wow, that's really humbling. Thanks so much for the kind words.


Dude, seriously. It's one of those books that just works. It's not too long, not too short. It's like Portal. Just long enough not to screw up. And trust me when I say all the thanks should go to you. Awesome book.

The video is what sold me. I hadn't realized what I was missing until I watched that brief video you put out. It was, if anything, enlightening. I knew this stuff could be done, but it suddenly seemed so much easier, and well worth the investment.

What I'm trying to say is, if you have other ideas for writing a book about various other tools, get to work.


Please make your book available via Google Books if possible! I'd really love to purchase it, but I like to read in between devices and Google Books is the only platform that supports this well right now. Also, I like to keep it attached to a single account instead of having to spread my credit card details everywhere.


The book is available in DRM-free epub, mobi, and PDF, and PragProg.com can deliver your books to a Kindle or Dropbox automatically. That's how I read books across my devices.


I'd also recommend this book! Worth the read.


For anyone wondering what this vim/tmux thing is about, what it looks like and what it can do (and seeing the questions in the rest of the comments, there are a few), click the link to that book and check the video. I was only vaguely familiar with tmux (as in I knew it's some sort of `screen`) and this really made it clear to me.

As soon as I put Linux on this machine I'll give it a try, too :)


I do something similar but instead of tmux in a terminal, I use a tiling window manager (called awesome) to achieve a similar user experience but with all GUI windows instead of only terminal windows. (it's not a daemon like tmux, though).

This way, I can also get a browser window in the mix too, or any other windowed application. I also prefer using gvim and not console vim, because I can have a different coding font and drag and drop files from my version control GUI (an enterprise VCS with a really crappy CLI, guess which one).

Switching to a tiling window manager is perhaps the best productivity booster I've had. It even allowed me to start working comfortably with one display only or a laptop display, I've always used multiple displays before.


I do exactly the same thing. It works really great for me. An additional plus if you go this route is the tagging feature of tiling window managers. This allows you to have multiple views. I use for example one e-mail/web view, one development view (vim in multiple consoles), one server view (consoles connected to various remote systems) one Matlab view and of course one music player view.


I do this. Vim + tmux rocks.

One tip that Works For Me (tm) is to map the rarely-used function keys to pane and window selection commands (I hate multi-key commands :))

I've got F1/F2 mapped to cycle through panes, and F3/F4 to cycle through windows, F5/F6 to split windows, F7/F8 to resize panes, and F9 to open a new window.

Also, I always run my tmux terminal fullscreen and without the menubar.

YMMV.


Can you post/pastebin your config for this function keys mapping? thanks!

P.S. dont you have problems using tools like "top" and so on?


Hope this helps. It's nothing fancy. No, no probs with 'top'.

    # use ^K instead of default ^B.
    set-option -g prefix C-k
    unbind-key C-b
    bind-key C-k send-prefix
    
    # F1, F2 to cycle between windows within a "workspace".
    # what tmux calls "windows" are like workspaces in WindowMaker.
    # and what it calls "panes" are like individual xterm windows in a workspace.
    bind-key -n F2 select-pane -t:.+
    bind-key -n F1 select-pane -t:.-
    
    # F3, F4 to cycle between workspaces.
    bind-key -n F3 previous-window
    bind-key -n F4 next-window
    
    # F5 split a workspace horizontally and F6 to split vertically.
    bind-key -n F5 split-window
    bind-key -n F6 split-window -h
    
    # F9 new workspace
    bind-key -n F9 new-window
    
    # to disconnect from tmux do: ^K+d
    # or exit all the windows you created.
    bind-key -n F7 resize-pane -L
    bind-key -n F8 resize-pane -R


Thank you, unfortunately I dont know why but F1-F4 are not working, while F5,F6,F9 works. I'm using putty, dont know if this matters. When i press F1,F2,F3,F4 i got ~ on the shell


Sorry, I just saw this. And I'm right now on Linux so I can't confirm, so I might be slightly off here.

There's a setting under keyboard (or terminal, I forget). You might need to change it to 'X11R6'.

Look at section 4.4.3 here: http://the.earth.li/~sgtatham/putty/0.62/htmldoc/Chapter4.ht...

I hope that fixes it for you. Good luck.


I have been using tmux + vim as my primary mode of work for quite some time now, and as time has gone on my productivity has markedly increased as a result. I don't think I could ever go back to a workflow that required me to use a mouse or be away from all of the standard linux utilities and pipes.


I used to do the same, recently I switched to MacVim. I found using Vim in Terminal/iTerm2 slowed down drastically after I worked with it for 10-15 minutes. Opening a file would take 1-1.5s, compared to MacVim which was instantaneous. I thought it was tied to a plugin, tried going barebones and still the same problem. (Although removing vim-rails sped it up a tiny bit.) Unable to diagnose it any further, I had to switch to MacVim.

Anyone else had similar problems and managed to resolve? Here is my dotfiles if you're curious https://github.com/jeyb/dotfiles.


This is an honest question from someone with 0 experience with TMux. What benefit does it give me over using split windows within iTerm?


You can ran tmux on a remote server, and then deliberately disconnect, or have the line drop. You then ssh back in, 'tmux attach' and your state is still there.

So you can have a headless box or dedicated server running tmux. In the session is your development work, irssi irc clients, documents you frequently edit. They can run for months or years. You could be on your laptop or system at work or desktop at home, and you ssh in with xterm/iterm/putty and type 'tmux attach' and you're home again. I made a datacentre trip a few weeks ago and was working on some stuff from a crash-cart monitor to a unix tty. My session came up, I was back home.

If you have iterm, then you're tied to Mac OS X. The developer or Apple can change something (they're prone to doing this) and then you get left in the cold.

Tmux is a different way of looking at the world, that makes the workstation you're running on mostly irrelevant. With the tmux approach your workstation needs become trivial. Do I have ssh? Perhaps - do I have a web browser? OK - go.

The unix toolchain offers an opportunity to learn a complementing set of weird but really powerful tools once, an then iterate. As time goes on you get better and stronger with them, and can ride them forward for your career/life.


I've never used iTerm, but does iTerm run from a daemon and remember your window config even when you close the window?

The main use case for that in tmux is when you ssh into a server, start tmux and vim, do some work, then log out without shutting down the tmux daemon. You can then log back in the next day, reattach to the tmux daemon, and continue with your tmux layout the way it was when you logged out the previous day.


No, but they maintain a fork of tmux that integrates into the iTerm UI to provide that type of functionality. It's a work in progress, but it's coming along nicely.

http://code.google.com/p/iterm2/wiki/TmuxIntegration


honest question... but how is this different from running an emacs server with split windows/buffers plus a console emulator that supports multiple sessions?

ex. i use yakuake (KDE) with three sessions. one with an emacs buffer and the CLI, one session dedicated to wanderlust, and one running erc. if i do some dev work i just add another session and fire up emacsclient to connect to the running emacs instance. this can be adopted for use in a server environment, you just ssh in and hit 'emacsclient' to connect to emacs instance. screenshots: https://plus.google.com/photos/111355179120790769944/albums/...


It's.. vim?

Posts about using vim and tmux are pretty obviously not pointed at emacs users.


vim can split windows as well, and most terminal emulators support split sessions... my real question is what is the real benefit of tmux?

i'm not trying to start a flame war here, i used to use vim until i got into lisp. i'm always interested in looking into different workflows.


It's a different way to do more or less the same thing.

The differences:

* The editor is Vim not Emacs.

* Vim is not able (without unconvincing plugins/hacks) to run a shell in a window so if you need one you are pretty much forced to run it somewhere else. Be it another terminal emulator instance, another terminal emulator window, another terminal emulator split window (like you do), in the same terminal emulator window (juggling with Ctrl+z/fg), another window in tmux/screen, another pane in tmux/screen, etc.

* Yaquake is a GUI app that you can't realistically run on a remote server while tmux is CLI-based. When SSHing, tmux is possibly the closest thing there is to Yaquake.

* Tmux and screen both allow you to attach/detach sessions which makes these tools very useful on remote machines where they are commonly used to launch servers or long running tasks.

* Probably many more…

Note that these are DIFFERENCES. They CAN be benefits, depending on your workflow and needs.

Totally OT. I know about Yaquake since years. I know about Quake since much longer. I know that Yaquake "top-sliding" UX is based on Quake's console since all those years. Yet I've just realized, now, that the "quake" in Yaquake is actually "Quake" and that, for all those years I've pronounced it in a kind of japanese-style "Yakuake". Oh well…


tmux splits shells into windows. The suggested workflow is to have vim in one split window, and other shells in other windows.

tmux has the benefit of a keybaord-driven interface to jump between terminals, so it's not unlike having Emacs running with various vertical and horizontal splits running console buffers (which is something Vim doesn't support well natively.)

It gives Vim users the kind of workflow that some other tools provide natively with a completely keyboard-driven interface.


If you run them in Putty fullscreen folks don't even have to know you use Windows!


I've been using tmux for the last year or so, and feel lost developing without it; I use tmuxinator and have it open tabs called editor, shell, vm, db, logs, scm (with a slightly different setup per project) and it works fantastically.

https://github.com/aziz/tmuxinator


Two things that I really like about my IDE is the project file explorer and working on multiple files using tabs. Part of that is not just the quick access, but visually seeing what I have open. Are there equivalents for those things with the tmux/vim setup?


vim supports tabs (as well as windows). tmux also supports "tabs" as well, which you can rename. I currently have about 6 tmux tabs open, each split with various windows. Some will have vim inside, and vim will have it's own windows and tabs separate from tmux. It sounds confusing, but it's actually very simple to keep everything straight.

My tmux tabs are all named for their purpose. So, if I'm working on different areas in a project, I can easily move to that area and focus on that.

tmux also supports having different sessions. So, I can open one session, and if I have to move to a completely different project, I can open up a session for that.

As for file access, their are numerous plugins for vim that accomplish that. I think they are NerdTree and something else I can't remember? Not sure, I don't use them. With tmux, I can have a pane opened up and just use the command line to see everything.

But as for seeing what you have open, tmux and vim give you numerous ways to do this, as well as move through all those screens, easily in many different ways, far easier than any IDE I've ever seen.


> As for file access, their are numerous plugins for vim that accomplish that. I think they are NerdTree and something else I can't remember?

Command-T probably.

https://wincent.com/products/command-t


That's it. I knew if I mentioned it, someone would pop in to help. =)


The only vim module I can't get by without.


It sounds confusing, but it's actually very simple to keep everything straight.

Perhaps some screenshots would be enlightening for jakejake?



hehe awesome - thanks!


cool, thanks for answering. I really like using a standard IDE for coding and my terminal stuff is pretty much limited to working on the server. I do find it impressive when I see friends and co-workers blazing around in the terminal.


I might be attracting a lot of heat towards me but can somebody post something similar about emacs as well. I had seen one of my friend doing it once but it didn't work very well and I was pretty unfamiliar to linux at that point of time.


Other than the vertical split, does tmux do anything that GNU screen can't do? I find screen is more readily available on a wide variety of systems.


Tmux is easier to customize, more stable and being actively developed.

Whereas GNU Screen has been declared an unmaintainable pile of spaghetti code and left to bitrot.

The King is dead! Long live the King!


If you want to go IDE qua IDE, with the shell linking everything up, tmux is much easier to control from the command line than screen is. The multiple sessions business is actually quite cool with a utility like tmuxinator; you can switch to and from them and retain clipboard status, etc. The way the window splitting works reminds me a lot of xmonad (which I also run) and I'm not sure yet which mode of use I like better. Screen doesn't handle multiple clients with different window sizes especially gracefully; because I run tmux and xmonad I tend to have weird shaped windows, which behave exactly as you might hope with multiple clients.

I'm not sold sold on tmux over screen, but I do like what I'm seeing.


Configuring tmux is easier than configuring screen. And you can patch screen to do vertical splits. The patched screen has been the one that installs in Ubuntu for some time now.


For some reason the vertical split patch (available on Macports) stopped working once I upgraded to OSX Lion and I find myself depending on terminal "tabs" to mimic it (which is slow and painful). Well, maybe it's time to make the move to tmux!


IIRC screen does not remember your split window configuration when you detach.




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

Search: