rumpel
rumpel

Reputation: 83

Vi syntax-highlighting after executing vi within bash script

I created this Stackoverflow account only for asking this question:

Is there a way to tell Vi to do syntax-highlighting when executing it from within a script like this:

#!/bin/bash
vi /path/to/script.sh

I was trying things like this and other stuff like sudo su - in order to reset the environment, but nothing worked..

Any chance a to make it work(preferably without editing the .vimrc)?

Thanks :)

Upvotes: 1

Views: 452

Answers (2)

Erich Baumgartner
Erich Baumgartner

Reputation: 1

On most Unix systems, vi is not vi itself, but a symlink to /etc/alternatives/vi, which itself is a symlink to a vi-alike editor. You can find out which editor that is with the command ls -l /etc/alternatives/vi. Fabio Almeida clearly has vim, which has syntax highlighting, but you might have an editor like nvi, which doesn't. To use it, you would have to install a different editor (like vim).

Upvotes: 0

3ximus
3ximus

Reputation: 391

You can run a command when you launch vi after the file is loaded:

vi -c "syntax on" /path/to/script.sh

That should turn on syntax highlighting

Upvotes: 2

Related Questions