Blaszard
Blaszard

Reputation: 31985

Make some functionalities work only in MacVim, but not on Vim from within Terminal

I use Vim mostly through OS X's MacVim application, but I also use it from within Terminal. However, since I use the following vim code in order to make use of session to keep previous files always open in next session:

In ~/.vimrc:

function! RestoreSession()
  if argc() == 0 "vim called without arguments
    execute 'source ~/.vim/Session.vim'
  end
endfunction
autocmd VimEnter * call RestoreSession()

when I use MacVim, there are no issues there, but when I use Vim from within Terminal, whenever I type in commands (vim) and start to use it, I first got a lot of error messages like Error detected while processing /Users/myUserName/.vim/Session.vim: line 265: "path/to/my/file.js" 19L, 626C

So I wonder what is the best way to cope with the above issue:

I'd like to take the second solution if it is feasible, but how can I do it? And are there other solutions that you know are better in this situation?

Thanks.

Upvotes: 0

Views: 112

Answers (2)

Matthew Strawbridge
Matthew Strawbridge

Reputation: 20630

Put any settings that you only want to use in the GUI version into a .gvimrc file instead.

Upvotes: 0

Ingo Karkat
Ingo Karkat

Reputation: 172648

Unless you can figure out what's the root cause of the errors (and as you're apparently content with the restore even with those errors), you can suppress them via:

silent! execute 'source ~/.vim/Session.vim'

Upvotes: 1

Related Questions