I have been having some problems using UltiSnips with vim. It seems that :mksession is adding a bunch of nonprintable characters to my session file(s). When this is sourced to restore my session, UltiSnips has a problem dealing with these nonprintable characters. Does anyone know why vim might be adding these nonprintable characters to my session file?

The following are the two vim commands that I'm using to save a session and source a session.

nmap <F2> :wa<CR>:mksession! $HOME/vim_session<CR> " Write session to file

nmap <F3> :wa<CR>:source $HOME/vim_session<CR> " Load session from file

Screenshot of gVim session file with many nonprintable characters

  • Are you by any chance "lazy"-loading the UltiSnips plugin? Perhaps the cause is not related to unprintable characters, but with plugin loading "moment".
    – VanLaser
    Apr 1, 2016 at 18:03
  • Yeah, the developer of UltiSnips thinks it's not a problem with unprintable characters, either. However, it's weird that those characters are being inserted. Any idea why that would be? I'm using Vundle to manage my plugins. It does not allow me to load UltiSnips lazily like NeoBundle does. So, no, I'm not lazily loading them. They are being loaded as soon as a session is restored. Apr 1, 2016 at 18:35
  • 1
    Why do you think it's weird? This is the default behavior.
    – romainl
    Apr 1, 2016 at 18:41
  • 1
    In Vim, you can literally type Ctrl-V Enter to get something equivalent to what you would otherwise type as "\r", "\n", "\<CR>" etc. (depending on context). Vim would then show this as "^V^M", which actually means "literally a carriage return". What I see in your screenshot is what UltiSnips author told you - Vim representation of raw characters, replacing (but equivalent) to the ones you specified in your maps.
    – VanLaser
    Apr 1, 2016 at 20:09
  • 1
    Right, I totally understand that much. What I don't understand is why those raw characters would be in my session file. Newlines, carriage returns, line feeds, those are understandable. bel, device control 2, end of medium characters don't belong in a session file as far as I can determine. That's what this question is asking: Why are weird (i.e. not formatting/newline characters, but other strange raw characters) showing up in my session file? Apr 1, 2016 at 20:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.