Sharing dotfiles between Windows and Ubuntu

Link. May 9, 2008. Comments [1]. Posted in: Tools

I have several configuration files I keep on my home folder for several applications, most of which is what in Unix-speak is usually known as "dotfiles". This includes things like my VIM configuration and runtime files, my Unix and PowerShell profile scripts and so on.

Naturally, I want these to be available on all of my machines, and synchronizing them manually has always been a drag, but so far, I had not really looked too hard at how to avoid it.

The most natural way to do this was, of course, source control, which I wanted to have anyway. It was easy enough to use SVN or GIT for this, but one thing had prevented me from going this way: File name conventions.

A few weeks ago I ranted about how some cross-platform applications would use a different set of file/folder names when running on windows instead of Unix, and how this was a nasty legacy coming from the old FAT/FAT32 days, but was not so much of a problem with NTFS.

There was a point to that rant, very related to today's post: What prevented me from using simple source control to share my dotfiles between my Windows machines and my Ubuntu machines was exactly this issue with the renamed dotfiles.

In particular, one of the things that constantly nagged me was having to rename my _vimrc and vimfiles/ directories from Windows to .vimrc and .vim/ when synchronizing them to the Ubuntu machines. It was a royal pain, and one that source control wouldn't solve at all.

Fortunately, turns out there's an easy way to avoid this with GVim on Windows, so that I could use .vimrc and .vim/ there as well:

  1. It appears that .vimrc is natively supported in modern VIM versions. I don't know when this came to happen, but I just renamed my _vimrc to .vimrc and it just worked. Pure goodness.
  2. Renaming vimfiles/ to .vim didn't work right out. But, fortunately, you can change the set of folders that VIM will look into when loading runtime files by modifying the runtimepath option. So I just added this right at the top of my .vimrc file:
set runtimepath=~/.vim,$VIMRUNTIME,~/.vim/after

Restarted VIM, and it just worked. Fantastic! I'm now simply using git to keep my dotfiles in source control and synchronizing them between machines is simply a matter of doing git pull/push every once in a while. Very nice.

Vim Scripts

Link. May 1, 2008. Comments [1]. Posted in: Tools

Someone recently asked me what Vim scripts and plug-ins I use on my Vim setup. There are literally hundreds of plug-ins on the Vim site, some of them quite complex and interesting.

Though I've customized my own Vim setup quite a bit, I don't use all that many plug-ins. Here's what I normally use:

Plug-Ins

  • Calendar: Displays a calendar in a Vim buffer. Though not as complete as the functionality in Emac's calendar, it is still pretty useful :-).
  • Camelcasemotion: This one adds word-movement navigation motions that are aware of the casing of characters inside words. So, for example, if you're at the beginning of "newIdentifier" and press ",w", you'll navigate to the 'I' instead of to the end of the complete word like with "w".
    This is one of the features I missed the most from Eclipse. Unlike Eclipse, though, I rather like how with Camelcasemotion I can keep both behaviors at the same time.
  • NumberMarksNumber Marks:  Allows you to define numbered marks that behave a lot more like bookmarks in Visual Studio (you can even navigate them using F2!). The nice part about this one is that it will show the mark in a column to the left of the text, unlike regular Vim marks which are hidden.

    While on the topic of marks, there's also ShowMarks, which solves the issue of the hidden Vim marks: It also adds a new column at the left of the editing window showing which marks have been defined and where in the current document. It does its job, but I've found it to be more intrusive than Number Marks and it also seems to cause some issues with a few other plug-ins at times, which is why I don't like it as much.

  • NERD_Tree: Provides a "side pane" for browsing the file system and opening files within Vim, which is sometimes better than simply opening up a directory in the main buffer. I've hooked it up so that Ctrl+E,Ctrl+E pops up the tree.

    NerdTree
  • Obvious Mode: Great little plug-in recently released that highlights the status bar in a different color when you're in insert mode. This is particularly useful for me when working on the console version of Vim (which I do every so often) because I don't normally get the block-vs-line cursor difference that's common in GVim.
  • VimExplorer: For more complex file browsing and file manipulation options, I also use VimExplorer occasionally. This is more like Windows Explorer embedded inside Vim [screenshot], so it is a lot more complex than NERD_Tree, and has a lot more options. I use it a lot less, but it's still pretty useful.
  • Xmledit: Makes editing XML files in Vim a bit nicer, adding things like automatic insertion of closing tags.
  • Xmlpretty: Helps in doing a basic pretty print formatting of XML files. It's not very sophisticated, but it's occasionally useful. The downside of Xmlpretty is that it requires a bit more work to setup than other scripts since it doesn't configure itself automatically. I bound it to Ctrl+K, Ctrl+F.
  • Cream: Cream is sort of an alternate, highly customized distribution of Vim that makes it behave more like "normal" text editors (particularly for Windows users). I don't use Cream per-se, but I've occasionally plucked some functions from the cream source for my own Vim setup. In particular, I use Cream's functions for tab-ifying lines of text in select mode.

Syntax and Others

Besides the built-in syntax, indent and file type plug-ins that come with the Vim runtime, I use a few other ones:

  • CssColorCSS Color:  Cool little plug-in that highlights color specifications in CSS with the color they represent. I've found this particularly useful when modifying or inspecting an existing CSS file.
  • PS1: I use slightly modified versions of Peter Provost's indent, syntax and file type plug-ins to edit Windows PowerShell scripts.
  • CSharp: A slightly modified version of the Built-in cs.vim syntax file. It's ok, but could use a bunch of improvements, I mostly just browse C# code on Vim, though, so it's not that big of a deal.

Color Schemes

Like with Visual Studio, I change the color schemes I use in Vim every so often. Here are some of the ones I use the most:

  • Moria: A nice color scheme for Vim featuring versions with both dark and black background colors. Lately I've been using the version with the black background more (:Colo Black).
  • Twilight: This is another dark color scheme, with some some khaki/gold highlights. It works particularly well for source code from scripting languages like Ruby, PowerShell or Python, though not as well for C# and Java code. For some reason, however, this looks a lot better on my Ubuntu machine than on my Windows one (something to do with gamma correction I'm sure).
  • Wombat: I've talked about wombat before. Lately I haven't been in love with it so much and have switched to some of the other ones.
  • Zenburn: This is an old time favorite of many Vim users, and it's a really nice color scheme. I've been using this one a lot more lately, as it has fairly soothing colors, without being so low-contrast that it becomes harder to use with the LCD brightness turned down.
    I use Zenburn with the "zenburn_high_Contrast" option enabled, though, which makes the background slightly darker than what this screenshot shows.
    The CSS I'm using to highlight my code samples in this blog lately is Zenburn.
  • DarkSpectrum: This one I've been using lately as well. It features a darkish gray background with blue/gold/orange/green highlights and some bold white for keywords and such [screenshot]. It doesn't work as well for some languages, most notably Vim scripts themselves, though.
  • Impact: This is the one I use for console vim, as it works better with the limited color palette available there (particularly on windows).

Vimperator and Firefox 3.0

Link. April 30, 2008. Comments [0]. Posted in: Tools

Just so that I know where to find them (as I always forget):

You can find Vimperator 0.6 builds that work with the Firefox 3.0 betas here: http://www.calmar.ws/firefox/vimperator/

They are updated every so often, so it's useful to keep checking them. I've been using them a few weeks now and it's been working mostly fine!

Editing PowerShell Scripts with Vim

Link. March 18, 2008. Comments [0]. Posted in: PowerShell | Tools

I've been using Vim to edit my PowerShell scripts for a while. I get full syntax highlighting and indentation thanks to Peter Provost's excellent scripts:

These work great most of the time, but a couple of things had been nagging me for a while:

  1. I occasionally enable syntax-based folding (:set foldmethod=syntax), but the PS1 syntax file doesn't enable this for blocks "{...}" in PowerShell scripts.
  2. The indent file always forces comments (#...) to start at the first column.

Fortunately, both of these issues are pretty easy to fix. To enable syntax-based folding, I just modified the syntax file to add this:

" support folding for blocks
syntax region  psBlock      start="{" end="}" transparent fold

To disable the comment indentation, I edited the Indent file and remove the # character as an indent key:

setlocal cindent cinoptions& cinoptions+=+0 cinkeys-=0#

Seems to be working fine for me, and it will now stop driving me crazy :-).

TortoiseSVN and Putty

Link. March 7, 2008. Comments [0]. Posted in: Tools

Last week, I was trying to connect to an SVN repository over SSH, using TortoiseSVN and Putty. I found a the faq on how to configure everything and checked it to make sure I was doing everything right.

I tried to connect. TortoiseSVN asked for my certificate password. And then, nothing. I could see that indeed TortoiseSVN was connecting to the SSH server; but just sat there doing nothing. I had to kill it several times to abort the connection.

I had already tried connecting using Putty directly, and that seemed to work, so I kept checking my settings, but for the life of me I couldn't figure out what the deal was.

Eventually, I figured out what the deal was:

puttyssh

See that "Don't start a shell or command at all" checkbox? Yep; that should NOT have been checked, as it prevented the server from starting svnserve to handle the SVN connection. Don't know why I had checked it before, but everything worked as soon as I removed it from my Putty profile.

About

Tomas Restrepo is co-founder of devdeo ltda. His interests include .NET, Connected Systems, PowerShell and, lately, dynamic programming languages. More...

email: tomas@winterdom.com
msn: tomasr@passport.com
twitter: tomas_restrepo

Technorati Profile

devdeo logo

View my profile on LinkedIn

MVP logo

Syndicate

Ads

Links

Tag Cloud

.NET (232) Architecture (47) ASP.NET (6) BizTalk (170) Blogging (64) C++ (3) Castle (2) Commerce Server (3) Development (118) DLR (7) Enterprise Services (25) Fonts (4) Host Integration Server (1) LINQ (3) Linux (5) NHibernate (1) Personal (143) PowerShell (22) QuickCounters (4) Tools (74) Vista (38) VS Color Scheme (10) VSTO (2) WCF (64) Web Services (87) WinFX (80) Workflow (47) WPF (5) XML (21)

Statistics

Total Posts: 986
This Year: 56
This Month: 6
This Week: 0
Comments: 755

Blogroll

Post Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 1.9.7174.0

Sign In