Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I open the recent file in the welcome page in a new tab without closing the welcome page? #556

Open
liuqin19980818 opened this issue Sep 30, 2024 · 0 comments

Comments

@liuqin19980818
Copy link

Dear author, hello! It is China's National Day now. I wonder if you have a day off. Thank you for your plugin, but I found a problem. It seems that it is not like tabnew <file_in_buffer>, but can only open one file. So I modified the code a little bit.

~/.vim/plugged/vim-startify/autoload/startify.vim

" Function: #open_buffers {{{1
" modified by liuqin19980818 2024-10-01 begin
" function! startify#open_buffers(...) abort
"   if exists('a:1')  " used in mappings
"     let entry = b:startify.entries[a:1]
"     if !empty(s:batchmode) && entry.type == 'file'
"       call startify#set_mark(s:batchmode, a:1)
"     else
"       call s:open_buffer(entry)
"     endif
"     return
"   endif
"
"   let marked = filter(copy(b:startify.entries), 'v:val.marked')
"   if empty(marked)  " open current entry
"     call s:open_buffer(b:startify.entries[line('.')])
"     return
"   endif
"
"   enew
"   setlocal nobuflisted
"
"   " Open all marked entries.
"   for entry in sort(values(marked), 's:sort_by_tick')
"     call s:open_buffer(entry)
"   endfor
"
"   wincmd =
"
"   if exists('#User#StartifyAllBuffersOpened')
"     doautocmd <nomodeline> User StartifyAllBuffersOpened
"   endif
" endfunction
function! startify#open_buffers(...) abort
  if exists('a:1')  " used in mappings
    let entry = b:startify.entries[a:1]
    if !empty(s:batchmode) && entry.type == 'file'
      call startify#set_mark(s:batchmode, a:1)
    else
      " 使用 tabnew 打开缓冲区
      execute 'tabnew ' . entry.path
    endif
    return
  endif

  let marked = filter(copy(b:startify.entries), 'v:val.marked')
  if empty(marked)  " open current entry
    execute 'tabnew ' . b:startify.entries[line('.')].path
    return
  endif

  " Open all marked entries in new tabs.
  for entry in sort(values(marked), 's:sort_by_tick')
    execute 'tabnew ' . entry.path
  endfor

  wincmd =

  if exists('#User#StartifyAllBuffersOpened')
    doautocmd <nomodeline> User StartifyAllBuffersOpened
  endif
endfunction
" modified by liuqin19980818 2024-10-01 end

I want to know if I can add a set of shortcut keys to open the newly opened file in a new tab so that I can use vim to edit multiple files at the same time.

Or you have already implemented it but I didn't find it in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant