Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  156] [ 0]  / answers: 1 / hits: 70843  / 2 Years ago, thu, february 24, 2022, 12:40:09

My Ubuntu LTS 12.04 has vim editor. If I open a file, move to a paragraph and reopen vim, then the cursor goes to beginning of the file always.



This is not the expected behavior. How the vim can remember last read position after closing a file?



I tried vi also, but the result is the same.


More From » vim

 Answers
4

The file /etc/vim/vimrc already contains necessary feature. Just need to uncomment it:


" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'"") > 1 && line("'"") <= line("$") | exe "normal! g'"" | endif
endif

(Infact, you can refer to /usr/share/vim/vim73/vimrc_example.vim also)


[#33989] Saturday, February 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amacal

Total Points: 457
Total Questions: 102
Total Answers: 116

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;