1

I am using the vim-fugitive plugin and I encounter a strange behaviour. I don't know if it's really related to the plugin or not.

I am trying to open the Gstatus page in a new tab. So I am creating a new tab and call Gstatus on the new tab :

:tabnew | Gstatus

And I get the following error :

E492: Not an editor command: Gstatus

Do you know what might cause the issue and how to fix it ? I can create a function to achieve this behavior, but I wanted to keep a mapping like the one I currently use :

nnoremap <Leader>gs tabnew | Gstatus<CR>

Edit :

  • When starting vim inside a git directory without a file, the Gstatus works.
  • When creating a new tab and running Gstatus by hand, the command failed, even if the pwd command shows the good directory.
  • Well, it's probably because when you create a new tab, you are also in a new buffer ... and :Gstatus needs the current buffer to be under version control (git). – VanLaser Sep 8 '15 at 11:07
  • I understand, but if I run the Gstatus command by hand after the newtab the command runs without problem – nobe4 Sep 8 '15 at 11:09
  • I just tested (with tabnew) and it doesn't. This is consistent with the docs :h fugitive-commands – VanLaser Sep 8 '15 at 11:11
  • My bad, it doesn't. I must have tested with a file open. I edited my question – nobe4 Sep 8 '15 at 11:13
  • BTW, Gstatus should not work without a file, even if in the right folder. It's the first item on the FAQ: github.com/tpope/vim-fugitive – VanLaser Sep 8 '15 at 11:20
6

Using <c-w>T to promote a window to a new tab.

nnoremap <Leader>gs :Gstatus<cr><c-w>T

For more help see :h CTRL-W_T

  • 5
    Or, purely in terms of commands, :Gstatus | wincmd T. – muru Sep 8 '15 at 16:41
5

I'll just quote from the official plugin FAQ:

FAQ

Q: I installed the plugin and started Vim. Why don't any of the commands exist?

A: Fugitive cares about the current file, not the current working directory. Edit a file from the repository.

Q: I opened a new tab. Why don't any of the commands exist?

A: Fugitive cares about the current file, not the current working directory. Edit a file from the repository.

It doesn't matter if you are, or not, in a Git controlled folder. :Gstatus is a buffer-local command, it will only be available if the currently loaded buffer deals with a file which is under git revision control. Therefore, when you open a new tab, the current buffer is an empty one, and :Gstatus is not defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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