Reputation: 527
One thing I find really annoying with NERDTree is that when I am opening a file that I just looked at five minutes ago, the file is opened at the very beginning as opposed to where the cursor was last.
I don't have this problem if I use the :b buffer list to open the file (it was already opened once), because I am transported directly to the place where my cursor was last. This is helpful because my source files are big.
Is there a way to make NERDTree look in the buffer list first to see if the file has already been opened? Or maybe there is some other way to solve my problem?
Upvotes: 3
Views: 908
Reputation: 15715
Inspired by this Vim tip I have the following in my vimrc, which will automatically move the cursor to its last position when it is opened. It seems to work fine with NERDTree
au BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
Note that the cursor position is stored in your viminfo file, and so the viminfo
option much be set appropriately. I think the default value is fine.
Upvotes: 5