# How do you return from 'gf' in Vim

I am making use of Vim for home windows mounted in Unix setting. Many thanks to this website I currently make use of the gf command to head to a documents under the arrow.

I'm seeking a command to either:

1. go back to the previous documents (comparable to Ctrl+T for ctags), or
2. remap gf to instantly release the new documents in a new window
199
2022-07-20 17:06:23
Source Share

I have not considered your gf command yet I visualize it makes use of the : e or : locate command.¢ Assuming that this is proper, merely change the : e or : locate with : new (or : vnew for an upright split) and also the documents will certainly open in a new window as opposed to the very same one.

for example

"Switch between header and cpp
nmap ,s :find %:t:r.cpp<CR>
nmap ,S :new %:t:r.cpp<CR>
nmap ,h :find %:t:r.h<CR>
nmap ,H :new %:t:r.h<CR>
nmap ,F :new =expand("<cfile>:t")<CR><CR>
nmap ,d :new =expand("<cfile>")<CR><CR>


0
2022-07-24 03:40:55
Source

You could intend to make use of CTRL-W gf to open the documents in a new tab.

You can close the freshly opened up documents as constantly with :bd, or make use of CTRL-6 and also various other common means of transforming barriers.

48
2022-07-24 03:30:33
Source

When you open a new file (with gf or :n or another command) the old file remains in a buffer list. You can list open files with :ls

If you want to navigate easily between buffers in vim, you can create a mapping like this:

nmap <M-LEFT> :bN<cr>
nmap <M-RIGHT> :bn<cr>


Now you can switch between buffers with Alt+ or Alt+.

The complete documentation on mappings is here:

:help map.txt

2
2022-07-24 03:06:22
Source

I obtained CTRL - Wf to work.¢ It is fairly disappointing that I've invested as long developing maps for these commands just to uncover that there are constructed - in variations.

6
2022-07-24 03:02:59
Source

I regularly make use of Ctrl - 6 for this.

It comes in handy due to the fact that it permits me to promptly leap to and fro in between both documents.

80
2022-07-22 17:09:54
Source

I do not recognize the response to component 2 of your inquiry, yet I can aid with component 1. Usage.

:e#


Vim keeps a checklist of files (barriers) that it is editing and enhancing. If you type

:buffers


it will certainly detail all the files you are presently editing and enhancing. The documents because checklist with a % close to it is the existing documents. The one with the # close to it is the alternative file.: e # will certainly switch over in between the existing and also alternative documents. As opposed to type that a lot, I map F2 to: e # so I can conveniently turn in between the existing and also alternative files. I map the command to F2 by including this to.vimrc

nmap <F2> :e#<CR>

5
2022-07-21 10:52:57
Source
2
2022-07-21 10:47:45
Source

I use Ctrl-O

311
2022-07-21 09:13:54
Source

Just make use of :e# adhered to by Enter - that primarily claims to modify the last (latest) documents.

15
2022-07-21 09:13:54
Source

Ctrl - Shift - 6 is one.

:e#↲ is an additional.

11
2022-07-21 09:13:30
Source

Related questions