I am looking to jump automatically to the last position in any file that I open.
I have in my ~/.vimrc file:
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
This works fine if I open a file using the vim
command.
But if I write vim .
in a directory to load netrw and use t
to open a file in a new tab, the cursor appears at the top of the file and not at the last position.
I then have to use `"
to jump to the last position.
Is there any way to jump to the last position when using netrw and t
?
Thanks.
I found an easy workaround. Just adding to ~/.vimrc
let g:netrw_browse_split = 3
allows me to hit enter
to open the file in a new tab and jump to the last position.
It is technically not a solution to the problem that I posted, but it works well enough for me.
I have also incorporated this: https://vi.stackexchange.com/questions/13344/open-multiple-files-in-tabs-from-explore-mode.
I just added
`\"
to a couple of lines to yield
let command .= "tgT`\":" . ( a:firstline + i ) . "\<CR>:+tabmove\<CR>"
and
let command .= "t`\"gT"
This allows me to open multiple files at once and to jump to the last position in each file.