Skip to content

Instantly share code, notes, and snippets.

@ehamberg
ehamberg / vim.bash
Created December 14, 2011 12:00
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