tags:

views:

66

answers:

2

I'm in the process of learning vim, and i just learned about marks. Before this i found it useful to have all the source code files i'm working on in their own tabs. When i found out about "global" (capital letter) marks i thought it would be a great way to switch to a tab which already has the marked file open, and scroll to the correct spot in a quick way. However, i found out that jumping to a mark in a different file simply changes the file which the current tab is displaying, and this messes up my tabs setup. Is there a way to make the marks work with the tabs in the way that i want?

A: 

Tabs may not be the best way to do what you are trying to do. When a file is open, it isn't necessarily open in just one tab. It's open in a buffer, which is a concept not tied to a tab.

In fact, you can have the same buffer open in multiple tabs (or even multiple panes within the same tab). A tab is more like a window into one or more of your currently open buffers.

It may be better to learn about how to switch between buffers in your current tab or pane. Just a suggestion.

thomasrutter
+1  A: 

The problem is that the mark-jumping commands are designed to move to the mark within the current window. You need to switch to a new window first using :sbuf or :tabnext or CTRL+WW. If you have set switchbuf=useopen,usetab then using :sbuf <otherfile> first will be sufficient to jump to the other tab where your file is open. But 'A will not create a new window for you (or re-use an existing one in another tab).

You can probably create a mapping for ' and ` which uses getpos(), setpos(), :sbuf, and switchbuf to jump to an existing window in another tab, but it would involve writing a page of vimscript.

See :help switchbuf and :help getpos() and :help setpos().

too much php