How do you return from 'gf' in Vim

前端 未结 11 1068
执念已碎
执念已碎 2020-12-12 09:23

I am using Vim for windows installed in Unix mode. Thanks to this site I now use the gf command to go to a file under the cursor.

I\'m looking for a com

相关标签:
11条回答
  • 2020-12-12 10:06

    I don't know the answer to part 2 of your question, but I can help with part 1. Use

    :e#
    

    Vim maintains a list of files (buffers) that it's editing. If you type

    :buffers
    

    it will list all the files you are currently editing. The file in that list with a % beside it is the current file. The one with the # beside it is the alternate file. :e# will switch between the current and alternate file. Rather than type that much, I map F2 to :e# so I can easily flip between the current and alternate files. I map the command to F2 by adding this to .vimrc

    nmap `<F2> :e#<CR>`
    
    0 讨论(0)
  • 2020-12-12 10:10

    Just use :e# followed by Enter - that basically says to edit the last (most recent) file.

    0 讨论(0)
  • 2020-12-12 10:14

    Ctrl-Shift-6 is one.

    :e#↲ is another.

    0 讨论(0)
  • 2020-12-12 10:15

    I use Ctrl-O

    0 讨论(0)
  • 2020-12-12 10:15

    I frequently use Ctrl-6 for this.

    It's handy because it allows me to quickly jump back and forth between the two files.

    0 讨论(0)
  • 2020-12-12 10:15

    You might want to use CTRL-W gf to open the file in a new tab.

    You can close the newly opened file as always with :bd, or use CTRL-6 and other usual ways of changing buffers.

    0 讨论(0)
提交回复
热议问题