I want a bash function to open the last file opened by vim and goes to a specfic line
I tried
vil()
{
vim -c "normal! '\''0 :$1"
}
A mark such as '0
actually works in Ex mode as well, for example :'0
will take you to the line of that mark, so for the first part, opening Vim on the last file edited, you can simply use:
vim -c "'0"
For the second part of jumping to a different line, you can simply use a separate -c
with a number, which will jump to that line.
Putting it all together:
vil() {
vim -c "'0" -c "$1"
}
Note again that this depends on $1
being a valid line number, which you might want to check in the function... In any case, this should address the issue at hand in your question.