[vim/vim] feat: tag jump support vertical split (PR #18845)

28 views
Skip to first unread message

glepnir

unread,
Dec 1, 2025, 2:26:16 AM (2 days ago) Dec 1
to vim/vim, Subscribed

Problem: Tag jump currently only works with horizontal splits, not vertical splits.

Solution: Add support for vertical splits using wincmd [ or ]

Most modern desktop monitors are quite large. With only horizontal splits, screen space isn’t fully utilized. Vertical splits could be more useful.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18845

Commit Summary

  • 921a3c8 feat: tag jump support vertical split

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845@github.com>

zeertzjq

unread,
Dec 1, 2025, 2:34:32 AM (2 days ago) Dec 1
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18845)

This seems a bit inconsistent. There are several different CTRL-W commands for tag jump with horizontal split, but you only added one command for vertical split here.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3595031319@github.com>

zeertzjq

unread,
Dec 1, 2025, 2:46:57 AM (2 days ago) Dec 1
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18845)

I also wonder if this should be controlled by the 'switchbuf' option instead. But it seems that this isn't what 'switchbuf' is meant for...


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3595072164@github.com>

glepnir

unread,
Dec 1, 2025, 3:33:41 AM (2 days ago) Dec 1
to vim/vim, Push

@glepnir pushed 1 commit.

  • 3e0666b feat: tag jump support vertical split


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/before/921a3c8fa9c428e9ef88034c16476f343e78fd5f/after/3e0666b5dde3ef9c90d75a23b1a44ca0d3fcb20a@github.com>

glepnir

unread,
Dec 1, 2025, 3:34:08 AM (2 days ago) Dec 1
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18845)

aha okkk added g[


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3595257643@github.com>

glepnir

unread,
Dec 1, 2025, 3:37:16 AM (2 days ago) Dec 1
to vim/vim, Push

@glepnir pushed 1 commit.

  • 2e7d9a8 feat: tag jump support vertical split

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/before/3e0666b5dde3ef9c90d75a23b1a44ca0d3fcb20a/after/2e7d9a8a9b575419861d153ff1779786ac60ba07@github.com>

BenYip

unread,
Dec 1, 2025, 11:20:55 AM (2 days ago) Dec 1
to vim/vim, Subscribed
bennyyip left a comment (vim/vim#18845)

Can we add an option to make all commands(:tag :tjump :help etc) that do horizontal split become vertical?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3597472689@github.com>

Christian Brabandt

unread,
Dec 1, 2025, 11:35:50 AM (2 days ago) Dec 1
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18845)

Can we add an option to make all commands(:tag :tjump :help etc) that do horizontal split become vertical?

A very long time ago, I wrote the splitvertical patch that would allow this. But I am not sure a general option is the best way. As a user I think I prefer having the full power of whether vim will split vertical or horinzontally, without having to toggle such an option all the time.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3597564876@github.com>

BenYip

unread,
Dec 1, 2025, 1:12:40 PM (2 days ago) Dec 1
to vim/vim, Subscribed
bennyyip left a comment (vim/vim#18845)

But I am not sure a general option is the best way. As a user I think I prefer having the full power of whether vim will split vertical or horinzontally, without having to toggle such an option all the time.

Now most commands split horizontally unless user prefix it with :vert[ical]. If the option is on, they split vertically unless :hor[izontal] is provided.
In this way, user still has full power controlling how to split.

Most modern desktop monitors are quite large. With only horizontal splits, screen space isn’t fully utilized. Vertical splits could be more useful.

I agree with this. For most of the time I use vertical split, so it would be nice if this is the default behavior, without prefixing :vert. And I already have a keymap to do what this PR does.

nnoremap <silent>'] <cmd>execute $"vertical ptjump {expand('<cword>')}"<BAR>wincmd =<CR>


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3598124878@github.com>

Christian Brabandt

unread,
Dec 1, 2025, 2:17:27 PM (2 days ago) Dec 1
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18845)

I also wonder if this should be controlled by the 'switchbuf' option instead. But it seems that this isn't what 'switchbuf' is meant for...

switchbuf applies to :stag commands, which is basically a way to split the window horizontally and open the tag window. So isn't this PR basically the same as :stag <C-R><C-W> when :set switchbuf+=vsplit ? Hm, no that currently does not work (I also do not see any test about vsplit). @yegappan I suppose this only applies to quickfix commands?

So how about then nnoremap <C-W>[ :vert :stag <C-R><C-W>? Do we really need this built-in?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3598451923@github.com>

Christian Brabandt

unread,
Dec 1, 2025, 2:22:30 PM (2 days ago) Dec 1
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/doc/windows.txt:

> @@ -880,6 +880,17 @@ the buffer.  The result is that all buffers will use the 'encoding' encoding
 		Does ":tag[!] [tagname]" and splits the window for the found
 		tag.  See also |:tag|.
 
+CTRL-W [						*CTRL-W_[*
+		Vertical split current window in two.  Use identifier under
+		cursor as a tag and jump to it in the new upper window.

Copy paste error? Should be like this instead?

⬇️ Suggested change
-		cursor as a tag and jump to it in the new upper window.
+		cursor as a tag and jump to it in the new window to the right.

In runtime/doc/windows.txt:

> @@ -880,6 +880,17 @@ the buffer.  The result is that all buffers will use the 'encoding' encoding
 		Does ":tag[!] [tagname]" and splits the window for the found
 		tag.  See also |:tag|.
 
+CTRL-W [						*CTRL-W_[*
+		Vertical split current window in two.  Use identifier under
⬇️ Suggested change
-		Vertical split current window in two.  Use identifier under
+		Like |CTRL-W_]|, but vertical split current window in two.  Use identifier under

In runtime/doc/windows.txt:

> @@ -880,6 +880,17 @@ the buffer.  The result is that all buffers will use the 'encoding' encoding
 		Does ":tag[!] [tagname]" and splits the window for the found
 		tag.  See also |:tag|.
 
+CTRL-W [						*CTRL-W_[*
+		Vertical split current window in two.  Use identifier under
+		cursor as a tag and jump to it in the new upper window.
+		In Visual mode uses the Visually selected text as a tag.
+		Make new window N high.
+							*CTRL-W_g[*
+CTRL-W g [	Vertical split current window in two.  Use identifier under
+		cursor as a tag and perform ":tselect" on it in the new upper
⬇️ Suggested change
-		cursor as a tag and perform ":tselect" on it in the new upper
+		cursor as a tag and perform ":tselect" on it in the new window to the right.

In src/testdir/test_tagjump.vim:

> @@ -1670,4 +1670,34 @@ func Test_tag_excmd_with_number_vim9script()
   bwipe!
 endfunc
 
+func Test_tag_jump_split()

there is no test for wincmd g[


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/review/3526595689@github.com>

glepnir

unread,
Dec 1, 2025, 10:19:59 PM (2 days ago) Dec 1
to vim/vim, Subscribed

@glepnir commented on this pull request.


In runtime/doc/windows.txt:

> @@ -880,6 +880,17 @@ the buffer.  The result is that all buffers will use the 'encoding' encoding
 		Does ":tag[!] [tagname]" and splits the window for the found
 		tag.  See also |:tag|.
 
+CTRL-W [						*CTRL-W_[*
+		Vertical split current window in two.  Use identifier under
+		cursor as a tag and jump to it in the new upper window.

oh right . but right or left depend on splitright


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/review/3527968064@github.com>

glepnir

unread,
Dec 1, 2025, 10:39:46 PM (2 days ago) Dec 1
to vim/vim, Push

@glepnir pushed 1 commit.

  • 29e3177 feat: tag jump support vertical split

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/before/f007fadf1f3e4bf080aa82fb5a2b134cd4a3292b/after/29e3177ae1ccb31325a887c9dc27c9eb291d99dd@github.com>

glepnir

unread,
Dec 1, 2025, 10:40:38 PM (2 days ago) Dec 1
to vim/vim, Subscribed

@glepnir commented on this pull request.


In src/testdir/test_tagjump.vim:

> @@ -1670,4 +1670,34 @@ func Test_tag_excmd_with_number_vim9script()
   bwipe!
 endfunc
 
+func Test_tag_jump_split()

also added more cases for wincmd (g)]


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/review/3528000173@github.com>

glepnir

unread,
Dec 1, 2025, 10:44:46 PM (2 days ago) Dec 1
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18845)

I suspect it’s mainly for historical reasons. Early desktop monitors were very small, and an 80-column text width was the common recommendation. In that era, horizontal splits for tag jumps made more sense. But modern desktop displays are much larger. Since we already have a built-in horizontal split, providing a built-in vertical split tag jump becomes meaningful as well, because the two would form a natural pair 🤔


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3600047412@github.com>

Yegappan Lakshmanan

unread,
Dec 2, 2025, 10:53:27 AM (20 hours ago) Dec 2
to vim/vim, Subscribed
yegappan left a comment (vim/vim#18845)

I also wonder if this should be controlled by the 'switchbuf' option instead. But it seems that this isn't what 'switchbuf' is meant for...

switchbuf applies to :stag commands, which is basically a way to split the window horizontally and open the tag window. So isn't this PR basically the same as :stag <C-R><C-W> when :set switchbuf+=vsplit ? Hm, no that currently does not work (I also do not see any test about vsplit). @yegappan I suppose this only applies to quickfix commands?

The 'switchbuf' option is used when splitting the window to edit a buffer and by the quickfix commands.
I will look into why this is not working with 'vsplit' when jumping to a tag later.

Regards,
Yegappan


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3602733610@github.com>

glepnir

unread,
Dec 2, 2025, 10:54:32 PM (8 hours ago) Dec 2
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18845)

So how about then nnoremap [ :vert :stag ? Do we really need this built-in?

It doesn’t seem to work. And g] / g[ can integrate with cstag and tselect. Since we already have Ctrl-W (g)], provide Ctrl-W (g)[ as a built-in feature would be better. It adds no mental overhead for users.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18845/c3604977897@github.com>

Reply all
Reply to author
Forward
0 new messages