Showing entries with tag "Vim".

Found 2 entries

Vim: Creating a portable copy of your configuration

If you use Vim on any regular basis you've probably created your own custom .vimrc file, and maybe installed a plugin or two. This config is machine specific and is not the easiest thing to move from one machine to another. I found this cool project called myvim that packages up your entire Vim installation into a single portable file. This file is a self-extracting archive of your Vim config that you can transfer to a new machine.

myvim -j /tmp/vim.bakers

This will create a file /tmp/vim.bakers which you can transfer and then run on a new machine.

Leave A Reply

Vim: Plugins written in Perl

Vim has it's own internal scripting language called Vimscript, which is complicated and only appropriate in Vim. Most versions of Vim ship with Perl support. I taught myself how to write a simple Vim script in Perl. The following will define a Vim function named CommaToggle, that calls a perl function named comma_toggle. This will toggle spaces after commas on/off.

function! CommaToggle()
perl << EOF

# Get the current line number, and line text
my ($line_num,$column) = $curwin->Cursor();
my $line               = $curbuf->Get($line_num);

if ($line =~ /,/) {
    my $fixed = comma_toggle($line);

sub comma_toggle {
    my $line = shift();

    if ($line =~ /, /) {
        # Remove spaces after commas
        $line =~ s/, /,/g;
    } else {
        # Add a space after commas
        $line =~ s/,/, /g;

    return $line;


Other Vim/Perl commands are available from the documentation. Then you can map a key combination to call that function:

nnoremap <Leader>, :call CommaToggle()<cr>
Leave A Reply