3

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.

anti-destin
  • 799
  • 1
  • 8
  • 19
  • While I think this is an interesting, well-written question, it's probably not on-topic for stack overflow. More importantly for you, you're more likely to get an expert answer from the [vi stackexchange](https://vi.stackexchange.com/) – jeremysprofile Apr 02 '19 at 19:00

1 Answers1

0

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.

anti-destin
  • 799
  • 1
  • 8
  • 19