![]() With a large monitor coupled with Google's extremely strict 80-character limit, you can easily have two or three files next to each other. Another advantage of buffers over tabs is that it allows you to have multiple windows open simultaneously in the same session: Ctrl-w v splits the main window horizontally, and Ctrl-w w switches between open windows (I've actually remapped Tab in normal mode to this). Especially with the latest version of Command-T which allows you to use the same fuzzy-matching search to switch between open buffers using b. Seriously, folks, if you're using vim, learn about buffers: they are great. One final update to my last post: I talked there about switching between tabs, but I've now stopped using tabs altogether. Better to learn the extra shortcut for those times when I explicitly need to copy out of vim. But I found that this ignores the difference between line-wise and character-wise selection, treating everything as character-wise, so cutting and pasting full lines inside vim becomes unnecessarily annoying. In bleeding-edge versions of vim later than 7.3.74, there is actually an additional option that you can use so that all yanks go directly to the X clipboard: set clipboard=unnamedplus. Now, in vim, you can yank to the X clipboard by using the + register, using "+y - I now have this mapped to Ctrl-C, which is close enough to the Mac's default of Cmd-C that I find it easy to remember. If the remote machine/VM is headless, it may not have any of the X stuff installed: installing the xauth package is probably enough to bring in the necessary dependencies, but I'm definitely not an expert here. The next step is to ensure that the SSH connection to the development machine uses X forwarding, which simply means using ssh -X when connecting. The version that Google had, luckily, already installed on my machine (2.7.0) includes a Pasteboard tab on the Preferences dialog which controls syncing between Mac Pasteboard and X clipboard - you need to tick "Enable syncing", "Update Pasteboard when CLIPBOARD changes", and "Update CLIPBOARD when Pasteboard changes". Although it might be possible to get it working with some use of defaults write, the easier solution is to use the open-source XQuartz project - it's the same as the supplied X11.app, but updated more frequently. There is an X11 app supplied with OS X, but (on Snow Leopard at least) it didn't seem to support the correct settings. To get this working, I needed to run an X server on my Mac and enable clipboard sharing - it needs to be running for this, even if you're not using any X applications. ![]() The basic principle is for the X clipboard to be shared with the OS X pasteboard, and then to to get vim to yank/delete to that clipboard. ![]() One missing element was the ability to cut-and-paste directly from vim into apps running on the Mac. ![]() Very useful: it involves compiling a custom version of tmux and some associated libraries on the server, but it's well worth it. Useful enough, but what iTerm2 adds is native support for tmux tabs and windows - so that they open as tabs/windows on the Mac desktop, and you can switch between them using normal Mac shortcuts rather than tmux-specific ones. Using any mulitplexer allows you to connect to a remote server with a single connection, and open as many tabs/windows to that connection as you like - and, what's more, you can detach your session when you log out and re-attach later, bringing your terminals back exactly how you left them. It integrates seamlessly with a custom version of tmux, the terminal multiplexer that's an alternative to GNU Screen. The latest version of iTerm2 has another trick up its sleeve. ![]()
0 Comments
Leave a Reply. |