Set VIM Open file cursor refers to the last exit location

Source: Internet
Author: User

I recently found in the process of using Vim to edit files, the open file cursor always stay at the beginning of the file, particularly troublesome, especially when the file is relatively large.

So I want to modify the Vim profile so that Vim remembers the last time the cursor exited.

The final problem is finally solved, so share it for everyone, hoping to help you.

My system is an Ubuntu system, adding the following in the file/ETC/VIM/VIMRC:

Au bufreadpost * If line ("'") > 0|if line ("'") <= line ("$") |exe ("norm" "") |else|exe "Norm $" |endif|endif

After setting, Vim opens a file and tries to find that you can remember the last cursor position.

You can also modify ~/.VIMRC or/ETC/VIMRC files for the Red Hat system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.