1

I have a very weird problem which did not exist in my environment before but now happened. When editing files, I'm used to doing this way:

  1. gvim . #open current directory browsing
  2. scroll up/down to select file, enter then edit.
  3. ctrl-6 #back to previous directory

However one day I found the step3 was failed, it said "No alternate file". My .vimrc file only contains:

colorscheme darkblue

set number

set autoindent

set nowrap

set ignorecase

set cursorline

I tried to clean all content in .cshrc but the same. Can anyone tell me what's wrong with my gvim ?

Thanks in advance.

Latika Agarwal
  • 973
  • 1
  • 6
  • 11
Jack
  • 13
  • 3
  • Unrelated, but if you are a netrw user, make sure you check out tpope's Vinegar plugin: https://github.com/tpope/vim-vinegar – Jonathan.Brink May 23 '18 at 19:36

2 Answers2

1

You are likely using netrw to edit a directory. This is the equivalent of :Explore. Sadly netrw has a bad habit of not maintaining the alternative buffer, #. You maybe able to upgrade netrw or use :Rexplore (:Rex for short) to resume exploring.

Another option is to just use :e with wildcards and tab completion to explore files. Use <c-d> to list out completions as well.

Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
1

This looks to be a change in behavior introduced in Vim 7.4. The netrw view is no longer stored as an alternate file. See this discussion.

The Vim maintainers seemed split on what the correct behavior should be, but Bram himself offered up this advice with a mapping:

I do realize that editing the directory of the current file is something I often do, but I never bothered to set up a mapping for it. Typing ":e %:h" is not too difficult, but CTRL-O to jump back to the netrw %directory view was easier.

I now added a mapping:

    map ,d :e %:h<CR> 

Let's see if I can get used to that.

Another related discussion can be found here.

Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115