1

I am trying to open a .zip file via vim. By default the cursor points to the bottom of the file once it opens. How can I bring the cursor to the beginning of the file as soon as I open a zip file?

How can I change the default behavior of the vim to point it to the beginning of the file as soon as I open a *.zip file?

2 Answers 2

0

Add this line to your ~/.vimrc:

autocmd BufEnter *.zip :0

From the Vim documentation:

                          *BufEnter*
BufEnter      After entering a buffer.  Useful for setting
              options for a file type.  Also executed when
              starting to edit a buffer, after the
              BufReadPost autocommands.

After entering the zip file, :0 should be executed (goto line 0).

0

You can use gg or :0 to go to the beginning of the file.

from :h gg

<C-Home>    or                  *gg* *<C-Home>*
gg          Goto line [count], default first line, on the first
            non-blank character |linewise|.  If 'startofline' not
            set, keep the same column.
2
  • yeah :) I know that. My question is how can I change the default behavior of the vim to point it to the beginning of the file as soon as I open a zip file
    – Thushi
    Jun 3, 2015 at 9:11
  • You can try starting vim without any plugins using vim -u NONE. I don't observe the behavior you are seeing. Jun 3, 2015 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .