Skip to content

Instantly share code, notes, and snippets.

@JoshuaGross
Last active December 15, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaGross/ad146e15c80ba7424ede to your computer and use it in GitHub Desktop.
Save JoshuaGross/ad146e15c80ba7424ede to your computer and use it in GitHub Desktop.
Open vim to a certain file, line, and (optionally) column
# https://gist.github.com/JoshuaGross/ad146e15c80ba7424ede
# Open vim to a certain file, line, and (optionally) column
function vimline {
col=$(echo $1 | awk '{split($0,a,":"); print a[3]}')
line=$(echo $1 | awk '{split($0,a,":"); print a[2]}')
file=$(echo $1 | awk '{split($0,a,":"); print a[1]}')
if [ -z "$col" ]; then
linecol="+$line"
else
linecol="+call cursor($line, $col)"
fi
vim "$linecol" "$file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment