13

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?

Eskil
  • 3,285
  • 5
  • 25
  • 31
  • Seems like it's not supposed to work like this. I might as well just use buffers i guess. – Eskil Jul 21 '10 at 08:48
  • 1
    See [this](http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers) question and answer, hopefully they will make this question go away :) – Randy Morris Jul 21 '10 at 12:36

3 Answers3

5

The problem is that the mark-jumping commands are designed to move to the mark within the current window as there can theoretically be many windows to the same file. 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().

blues
  • 3,926
  • 2
  • 19
  • 36
too much php
  • 85,414
  • 33
  • 126
  • 134
1

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
  • 109,718
  • 27
  • 142
  • 163
0
    nno \ <Cmd>call To_global_mark()<cr>
    fun! To_global_mark()
       -tab drop /tmp/useless.md
        exe 'normal! `' .. toupper(input("To global mark: "))
    endf
Good Pen
  • 437
  • 4
  • 7