2

My issue is with using the -c while calling vim from terminal like

$ vim -c jk

I want to be able to open the last session before quitting on typing viml in terminal

For this I made a map to save the session as 'zzz' on exiting vim. All that works perfectly.

Now I made an alias in my .zshrc/.bashrc:

# SLoad is from a plugin Startify, it loads the session  
alias viml='vim -c :SLoad zzz'   

But the issue I am facing is that when I run viml alias, this happens

image

Its really annoying that I have to press enter to start working. I tried using <cr> at end but it doesn't work.

How do I fix this?

0

1 Answer 1

3

The issue is that you need to escape your space:

alias viml='vim -c :SLoad\ zzz'   

Let's consider a simpler case:

I have a file named a.vim in the current directory and my alias is:

alias vv="vim -c :sp a.vim"

When I run vv I get two buffers with a.vim on each.

Why is that?

Vim open a.vim and then execute the command :sp, which split the buffer in two, opening a.vim again. The alias is used as follow:

 vim -c :sp a.vim

Which means vim a.vim and then :sp. :sp and a.vim are two different arguments.

Now I have the alias:

alias vv="vim -c :sp\ a.vim"

Vim open, and execute :sp a.vim, opening the a.vim file in a new split.

This is because the space is escaped and thus the :sp a.vim is one argument.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.