asked 190k views
3 votes
How to execute ls command inside a vi editor?
1) !ls
2) :ls
3) :!ls

asked
User MosGeo
by
7.9k points

1 Answer

5 votes

Final answer:

In the vi editor, the correct way to execute the 'ls' command is by entering ':!ls'. This command suspends the vi editor and executes 'ls' in the shell, allowing you to see the contents of the current directory before returning to the editor.

Step-by-step explanation:

To execute the ls command inside the vi editor, you can use the following command:

:!ls

This will temporarily suspend the vi editor and execute the ls command in the shell. The output of the ls command will be displayed, and after you press any key, you'll be returned to the vi editor. The commands !ls and :ls are not correct in this context; !ls is not a recognized command in vi and :ls lists the buffers in vim (an enhanced version of vi) rather than executing the shell ls command.

answered
User Zimi
by
8.2k points