Skip to content

Commit fe70e31

Browse files
committed
Improve opening in new/next tab
Now the first use creates a new tab. The following ones will use that tab too.
1 parent 8c3c84c commit fe70e31

3 files changed

Lines changed: 45 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ all available keys:
465465
| `x` | Close the split window containing selected buffer |
466466
| `X` | Leave the window containing selected buffer - close all others |
467467
| `t` | Open selected buffer in a new tab |
468-
| `T` | Open selected buffer in a new tab but stay in the plugin window |
468+
| `T` | Open selected buffer in a new (or next) tab but stay in the plugin window |
469469

470470

471471
#### Searching
@@ -648,7 +648,7 @@ list with the `r` key.
648648
| `s` | Open selected file in a new horizontal split |
649649
| `S` | Open selected file in a new horizontal split but stay in the plugin window |
650650
| `t` | Open selected file in a new tab |
651-
| `T` | Open selected file in a new tab but stay in the plugin window |
651+
| `T` | Open selected file in a new (or next) tab but stay in the plugin window |
652652

653653

654654
### Exiting

doc/ctrlspace.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*ctrlspace.txt* For Vim version 7.3+ Last change: 2014-08-29
1+
*ctrlspace.txt* For Vim version 7.3+ Last change: 2014-09-08
22
*ctrlspace*
33

44

@@ -480,7 +480,7 @@ listing of all available keys:
480480
| `x` | Close the split window containing selected buffer |
481481
| `X` | Leave the window containing selected buffer - close all others |
482482
| `t` | Open selected buffer in a new tab |
483-
| `T` | Open selected buffer in a new tab but stay in the plugin window |
483+
| `T` | Open selected buffer in a new (or next) tab but stay in the plugin window |
484484

485485

486486
3.1.1.3 Searching~
@@ -663,7 +663,7 @@ list with the `r` key.
663663
| `s` | Open selected file in a new horizontal split |
664664
| `S` | Open selected file in a new horizontal split but stay in the plugin window |
665665
| `t` | Open selected file in a new tab |
666-
| `T` | Open selected file in a new tab but stay in the plugin window |
666+
| `T` | Open selected file in a new (or next) tab but stay in the plugin window |
667667

668668

669669
3.2.3 Exiting~

plugin/ctrlspace.vim

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ function! <SID>goto_bookmark(bm_nr)
16371637
endif
16381638

16391639
silent! exe "cd " . new_bookmark.directory
1640-
call <SID>delayed_msg("CWD changed to '" . new_bookmark.directory . "'.")
1640+
call <SID>delayed_msg("CWD is now: " . new_bookmark.directory)
16411641
endfunction
16421642

16431643
function! <SID>change_bookmark_name(bm_nr)
@@ -2021,7 +2021,13 @@ function! <SID>display_help()
20212021
call <SID>key_help("s", "Open selected file in a new horizontal split")
20222022
call <SID>key_help("S", "Open selected file in a new horizontal split but stay in the plugin window")
20232023
call <SID>key_help("t", "Open selected file in a new tab")
2024-
call <SID>key_help("T", "Open selected file in a new tab but stay in the plugin window")
2024+
2025+
if s:open_in_next_tab_mode
2026+
call <SID>key_help("T", "Open selected file in the nex tab but stay in the plugin window")
2027+
else
2028+
call <SID>key_help("T", "Open selected file in a new tab but stay in the plugin window")
2029+
endif
2030+
20252031
call <SID>key_help("C-t", "Create a new tab and stay in the plugin window")
20262032
call <SID>key_help("Y", "Copy (yank) the current tab into a new one")
20272033
call <SID>key_help("=", "Change the tab name")
@@ -2105,7 +2111,13 @@ function! <SID>display_help()
21052111
call <SID>key_help("x", "Close the split window containing selected buffer")
21062112
call <SID>key_help("X", "Leave the window containing selected buffer - close all others")
21072113
call <SID>key_help("t", "Open selected buffer in a new tab")
2108-
call <SID>key_help("T", "Open selected buffer in a new tab but stay in the plugin window")
2114+
2115+
if s:open_in_next_tab_mode
2116+
call <SID>key_help("T", "Open selected buffer in the next tab but stay in the plugin window")
2117+
else
2118+
call <SID>key_help("T", "Open selected buffer in a new tab but stay in the plugin window")
2119+
endif
2120+
21092121
call <SID>key_help("C-t", "Create a new tab and stay in the plugin window")
21102122
call <SID>key_help("Y", "Copy (yank) the current tab into a new one")
21112123
call <SID>key_help("=", "Change the tab name")
@@ -2260,6 +2272,7 @@ function! <SID>ctrlspace_toggle(internal)
22602272
let s:bookmark_mode = 0
22612273
let s:last_browsed_workspace = 0
22622274
let s:restored_search_mode = 0
2275+
let s:open_in_next_tab_mode = 0
22632276
let s:search_letters = []
22642277
let t:ctrlspace_search_history_index = -1
22652278
let s:search_history_index = -1
@@ -3668,7 +3681,12 @@ function! <SID>keypressed(key)
36683681
elseif a:key ==# "t"
36693682
call <SID>load_file("tabnew")
36703683
elseif a:key ==# "T"
3671-
call <SID>load_many_files("tabnew", "tabprevious")
3684+
if s:open_in_next_tab_mode
3685+
call <SID>load_many_files("tabnext", "tabprevious")
3686+
else
3687+
call <SID>load_many_files("tabnew", "tabprevious")
3688+
let s:open_in_next_tab_mode = 1
3689+
endif
36723690
elseif a:key ==# "C-t"
36733691
call <SID>tab_command("T")
36743692
elseif a:key ==# "Y"
@@ -3755,6 +3773,7 @@ function! <SID>keypressed(key)
37553773
call <SID>kill(0, 0)
37563774
let s:file_mode = !s:file_mode
37573775
let s:workspace_mode = 1
3776+
let s:open_in_next_tab_mode = 0
37583777
call <SID>ctrlspace_toggle(1)
37593778
endif
37603779
elseif a:key ==# "W"
@@ -3764,18 +3783,21 @@ function! <SID>keypressed(key)
37643783
call <SID>kill(0, 0)
37653784
let s:file_mode = !s:file_mode
37663785
let s:workspace_mode = 1
3786+
let s:open_in_next_tab_mode = 0
37673787
call <SID>ctrlspace_toggle(1)
37683788
call <SID>switch_search_mode(1)
37693789
endif
37703790
elseif a:key ==# "l"
37713791
call <SID>kill(0, 0)
37723792
let s:file_mode = !s:file_mode
37733793
let s:tablist_mode = 1
3794+
let s:open_in_next_tab_mode = 0
37743795
call <SID>ctrlspace_toggle(1)
37753796
elseif a:key ==# "L"
37763797
call <SID>kill(0, 0)
37773798
let s:file_mode = !s:file_mode
37783799
let s:tablist_mode = 1
3800+
let s:open_in_next_tab_mode = 0
37793801
call <SID>ctrlspace_toggle(1)
37803802
call <SID>switch_search_mode(1)
37813803
elseif a:key ==# "b"
@@ -3785,6 +3807,7 @@ function! <SID>keypressed(key)
37853807
call <SID>kill(0, 0)
37863808
let s:file_mode = !s:file_mode
37873809
let s:bookmark_mode = 1
3810+
let s:open_in_next_tab_mode = 0
37883811
call <SID>ctrlspace_toggle(1)
37893812
endif
37903813
elseif a:key ==# "B"
@@ -3794,6 +3817,7 @@ function! <SID>keypressed(key)
37943817
call <SID>kill(0, 0)
37953818
let s:file_mode = !s:file_mode
37963819
let s:bookmark_mode = 1
3820+
let s:open_in_next_tab_mode = 0
37973821
call <SID>ctrlspace_toggle(1)
37983822
call <SID>switch_search_mode(1)
37993823
endif
@@ -3855,7 +3879,12 @@ function! <SID>keypressed(key)
38553879
elseif a:key ==# "t"
38563880
call <SID>load_buffer("tabnew")
38573881
elseif a:key ==# "T"
3858-
call <SID>load_many_buffers("tabnew", "tabprevious")
3882+
if s:open_in_next_tab_mode
3883+
call <SID>load_many_buffers("tabnext", "tabprevious")
3884+
else
3885+
call <SID>load_many_buffers("tabnew", "tabprevious")
3886+
let s:open_in_next_tab_mode = 1
3887+
endif
38593888
elseif a:key ==# "C-t"
38603889
call <SID>tab_command("T")
38613890
elseif a:key ==# "Y"
@@ -3979,6 +4008,7 @@ function! <SID>keypressed(key)
39794008
else
39804009
call <SID>kill(0, 0)
39814010
let s:workspace_mode = 1
4011+
let s:open_in_next_tab_mode = 0
39824012
call <SID>ctrlspace_toggle(1)
39834013
endif
39844014
elseif a:key ==# "W"
@@ -3987,16 +4017,19 @@ function! <SID>keypressed(key)
39874017
else
39884018
call <SID>kill(0, 0)
39894019
let s:workspace_mode = 1
4020+
let s:open_in_next_tab_mode = 0
39904021
call <SID>ctrlspace_toggle(1)
39914022
call <SID>switch_search_mode(1)
39924023
endif
39934024
elseif a:key ==# "l"
39944025
call <SID>kill(0, 0)
39954026
let s:tablist_mode = 1
4027+
let s:open_in_next_tab_mode = 0
39964028
call <SID>ctrlspace_toggle(1)
39974029
elseif a:key ==# "L"
39984030
call <SID>kill(0, 0)
39994031
let s:tablist_mode = 1
4032+
let s:open_in_next_tab_mode = 0
40004033
call <SID>ctrlspace_toggle(1)
40014034
call <SID>switch_search_mode(1)
40024035
elseif a:key ==# "b"
@@ -4005,6 +4038,7 @@ function! <SID>keypressed(key)
40054038
else
40064039
call <SID>kill(0, 0)
40074040
let s:bookmark_mode = 1
4041+
let s:open_in_next_tab_mode = 0
40084042
call <SID>ctrlspace_toggle(1)
40094043
endif
40104044
elseif a:key ==# "B"
@@ -4013,6 +4047,7 @@ function! <SID>keypressed(key)
40134047
else
40144048
call <SID>kill(0, 0)
40154049
let s:bookmark_mode = 1
4050+
let s:open_in_next_tab_mode = 0
40164051
call <SID>ctrlspace_toggle(1)
40174052
call <SID>switch_search_mode(1)
40184053
endif

0 commit comments

Comments
 (0)