![]() ![]() If you’re writing a PHP script, for example, you could use PHP’s syntax check option ( -l) to see if your script has any syntax errors: The bang command can be useful if you’re using Vim for programming. You wouldn’t want to run top or another interactive command using :! command, but you could drop to a shell and run such a command with :sh or Ctrl-z. Note that this command runs the file through the command, and not the contents of the buffer - so if you haven’t saved recently, it won’t report your most recent word count.īang works best with non-interactive commands. ![]() Vim will display the command output at the bottom of the editing window until you press Enter. This tells Vim to run the file ( %) through the wc utility and report the results. For instance, if you’re editing a file in Vim and want to find out how many words are in the file, run Vim also allows you to execute a command directly from the editor, without needing to drop to a shell, by using bang ( !) followed by the command to be run. Have you ever started editing a file, made a bunch of changes, and then typed :w to write your changes, only to find that the file is read-only? You can deal with that in a couple of ways, but one of the easiest things to do is to invoke a shell from within Vim and change the file’s permissions before you save it again. (This is a feature of the shell, not a Vim feature.) When you’re finished, you can resume Vim with fg. You can run whatever commands you want, and resume your Vim session by exiting the shell.Īs most other *nix applications, you can also pause Vim with Ctrl-z, which will drop you back to the shell. If you run :shell or just :sh while you’re in the editor, Vim (or Gvim, if you’re partial to Vim’s GUI) will place you in an interactive shell. ![]() However, Vim lets you access shell commands and utilities without leaving Vim, and that lets you perform some amazing tricks. Vim is a powerful editing tool, but there are some things it just can’t do. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |