Site Administration Page 5 - Vi 201 |
See Also: The guys who created vi built in all kinds of creature comforts designed to reduce your interaction with the shell to a minimum. One of the coolest ideas they came up with was a "shell filter", which allows you to replace shell commands with their output without needing to leave the editor at all. Try this - open up a blank document and type Now exit insert mode, position the cursor over the second "date" in that line, and type The line should now read or whatever the current date and time happens to be on your system. Vi passes the word under the cursor to the interpreter specified by the user - the "bash" shell, in this case - as a command, and then replaces the word with the output of that command. Despite these time-saving features, there are times when you'll want to execute a shell command directly. In vi, you can do this with So, if you needed a quick directory listing of the /home directory, you could type and vi would pass the command to the shell, and display the output to you. Finally, vi also allows you to spawn a new shell with the command. You can then execute shell commands and run other programs - even a new instance of vi, although only the truly warped among you would find this entertaining. Once you're done, simply log out of the spawned shell by typing and you'll be returned to your original vi session. This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |