Skip to content

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

@liuqin19980818

Description

@liuqin19980818

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions