Home > ansible, bash, vim > Running vim commands on the cli

Running vim commands on the cli

Problem:
I am trying to configure ansible to install some vim plugins. When doing this manually the steps are you git clone the repo, then run a vim command. How to do the same when using a script?

Solution:
From the vim manual

+{command}

-c {command}
{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must
be enclosed in double quotes (this depends on the shell that is used). Example: Vim “+set si” main.c
Note: You can use up to 10 “+” or “-c” commands.

–cmd {command}
Like using “-c”, but the command is executed just before processing any vimrc file. You can use up to 10 of these commands, independently from “-c”
commands.

Some examples:


vim "+PromptlineSnapshot ~/.shell_prompt.sh lightline" "+q"

or


vim -c "PromptlineSnapshot ~/.shell_prompt.sh lightline" -c "q"

Source:
http://stackoverflow.com/questions/12834370/run-vim-command-from-commandline

Advertisements
Categories: ansible, bash, vim Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: