Created
December 14, 2011 12:00
-
-
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:”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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