Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7582513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:27:10+00:00 2026-05-30T18:27:10+00:00

Is there any way to get vim to save the tab names (assigned via

  • 0

Is there any way to get vim to save the tab names (assigned via the Tab Name script) and/or a terminal emulator (set up via the Conque Shell script) upon issuing the :mksession [fileName] command?

Observe below (zoom in), I have a working session on the left, and the same session loaded via the vim -S fileName command, on the right. The assigned tab labels revert to absolute paths, ConqueShell terminal is interpreted as a file.

Failed Session

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:27:11+00:00Added an answer on May 30, 2026 at 6:27 pm

    After learning some basic VimScript I just gave up and used Python instead (to cite one example, you can’t save global information to a session if it is a list). Here is a solution I found for saving tab names (will post a solution for ConqueShell if I find one)

    Put the following in your .vimrc file and use whatever mapping you want to quickly save and load your sessions

    "Tokenize it so it has the following form (without spaces)
    "Label1 JJ Label2 JJ Label3 JJ Label4
    "Or if you prefer use something other than 'JJ' but DO NOT
    "use symbols as they could interfere with the shell command
    "line
    function RecordTabNames()
       "Start at the first tab with no tab names assigned
       let g:TabNames = ''
       tabfirst
    
       "Iterate over all the tabs and determine whether g:TabNames
       "needs to be updated
       for i in range(1, tabpagenr('$'))
          "If tabnames.vim created the variable 't:tab_name', append it
          "to g:TabNames, otherwise, append nothing, but the delimiter 
          if exists('t:tab_name')
             let g:TabNames = g:TabNames . t:tab_name  . 'JJ'
          else
             let g:TabNames = g:TabNames . 'JJ'
          endif
    
          "iterate to next tab
          tabnext
       endfor
    endfunction
    
    func! MakeFullSession()
       call RecordTabNames()
       mksession! ~/.vim/sessions/Session.vim
       "Call the Pythin script, passing to it as an argument, all the 
       "tab names. Make sure to put g:TabNames in double quotes, o.w.
       "a tab label with spaces will be passed as two separate arguments
       execute "!mksession.py '" . g:TabNames . "'"
    endfunc
    
    func! LoadFullSession()
       source ~/.vim/sessions/Session.vim
    endfunc
    
    nnoremap <leader>mks :call MakeFullSession()<CR>
    nnoremap <leader>lks :call LoadFullSession()<CR>
    

    Now create the following text file and put it somewhere in your PATH variable (echo $PATH to get it, mine is at /home/user/bin/mksession.py) and make sure to make it executable (chmod 0700 /home/user/bin/mksession.py)

    #!/usr/bin/env python
    
    """This script attempts to fix the Session.vim file by saving the 
       tab names. The tab names must be passed at the command line, 
       delimitted by a unique string (in this case 'JJ'). Also, although
       spaces are handled, symbols such as '!' can lead to problems.
       Steer clear of symbols and file names with 'JJ' in them (Sorry JJ
       Abrams, that's what you get for making the worst TV show in history,
       you jerk)
    """
    import sys
    import copy
    
    if __name__ == "__main__":
       labels = sys.argv[1].split('JJ')
       labels = labels[:len(labels)-1]
    
       """read the session file to add commands after tabedit
       " "(replace 'USER' with your username)
       "
       f = open('/home/USER/.vim/sessions/Session.vim', 'r')
       text = f.read()
       f.close()
    
       """If the text file does not contain the word "tabedit" that means there
       " "are no tabs. Therefore, do not continue
       """
       if text.find('tabedit') >=0:
          text = text.split('\n')
    
          """Must start at index 1 as the first "tab" is technically not a tab
          " "until the second tab is added
          """
          labelIndex = 1
          newText = ''
          for i, line in enumerate(text):
             newText +=line + '\n'
             """Remember that vim is not very smart with tabs. It does not understand
             " "the concept of a single tab. Therefore, the first "tab" is opened 
             " "as a buffer. In other words, first look for the keyword 'edit', then
             " "subsequently look for 'tabedit'. However, when being sourced, the 
             " "first tab opened is still a buffer, therefore, at the end we will
             " "have to return and take care of the first "tab"
             """
             if line.startswith('tabedit'):
                """If the labelIndex is empty that means it was never set,
                " "therefore, do nothing
                """
                if labels[labelIndex] != '':
                   newText += 'TName "%s"\n'%(labels[labelIndex])
                labelIndex += 1
    
          """Now that the tabbed windowing environment has been established,
          " "we can return to the first "tab" and set its name. This serves 
          " "the double purpose of selecting the first tab (if it has not 
          " "already been selected)
          """
          newText += "tabfirst\n"
          newText += 'TName "%s"\n'%(labels[0])
    
          #(replace 'USER' with your username)
          f = open('/home/USER/.vim/sessions/Session.vim', 'w')
          f.write(newText)
          f.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to get the column names from the pymssql results? If
Is there any way to GET the ContentValues object from the SQLite? It's very
Is there any way to get the ID of the element that fires an
Is there any way to get Python to use my ActiveTcl installation instead of
Is there any way to get the handle to the control that has focus?
Is there any way to get numbers on how many people are reading an
Is there any way to get the custom attributes of a specific object I
Is there any way to get the time down to the Millisecond in MySQL?
Is there any way to get the exposure settings (aperture, shutter speed, ISO) for
Is there any way to get a String[] with the roles a user has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.