Skip to content

Instantly share code, notes, and snippets.

@ehamberg
Created December 14, 2011 12:00
Show Gist options
  • Save ehamberg/1476311 to your computer and use it in GitHub Desktop.
Save ehamberg/1476311 to your computer and use it in GitHub Desktop.
bash function that allow vim to be called with “file.c:xx:yy:”
# make it possible to pass file names from gcc errors, e.g. “foo.c:3:14:”,
# directly to vim and have vim jump to line 3, column 14.
vim()
{
if [[ $# -eq 1 && $1 =~ (.*):([[:digit:]]+):([[:digit:]]+): ]]; then
FILE="${BASH_REMATCH[1]}"
LINE="${BASH_REMATCH[2]}"
COL="${BASH_REMATCH[3]}"
$(which vim) -c "call cursor($LINE,$COL)" $FILE
else
$(which vim) $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment