I am writing my first vimrc. I already read help pages for hidden and nostartofline options, as well as some articles and other FAQs.

However, I still can't understand what the purpose of these two options are.

2 Answers 2


Perhaps examples will help you understand the features:


  1. Start a new instance of Vim in the terminal with the command vim -Nu NONE. This will start Vim with default configuration, and thus 'hidden' will be unset (and 'startofline' will be set).

  2. Enter insert mode by pressing i, type in some text, and then press Esc to return to normal mode,

  3. Enter the command :e anotherfile.txt to start editing a new file,

  4. Vim will display an error because you haven't written the file yet,

  5. Enter the command :set hidden to switch on the 'hidden' option

  6. Try the command again: :e anotherfile.txt.

What happens?


  1. In the same instance of Vim, enter the command :b#to return to your original buffer.

  2. Press gg to jump to the beginning of the buffer and then $ to jump to the end of the line. (If the first line is blank, first enter some text.)

  3. Press gg again. The cursor will move to the start of the line.

  4. Press $ to move back to the end of the line,

  5. Enter the command :set nostartofline.

  6. Press gg a third time.

What happens?


Here are two additional examples for nostartofline.

First, open a new buffer, paste/type the following code, type :nostartofline, and then switch to Normal mode.

if (x == y) {



Example 1

  1. Place the cursor on x.

  2. Press VG to select the whole text.

  3. Notice your cursor is now on m and not d in dosomething2.

Example 2

  1. Place the cursor on d in dosomething1

  2. Press >> to indent this line.

  3. Notice your cursor was not moved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.