74 Part I . Linux First Steps . (Web hosting india)
74 Part I . Linux First Steps . :! command You can run a command while you are in vi using :! followed by a command name. For example, type :!date to see the current date and time, type :!pwd to see what your current directory is, or type :!jobs to see if you have any jobs running in the background. When the command completes, press Enter and you are back to editing the file. You could even use this technique to launch a shell (:!bash) from vi, run a few commands from that shell, and then type exit to return to vi. (I recommend doing a save before escaping to the shell, just in case you forget to go back to vi.) . — INSERT When you are in insert mode, the word INSERT appears at the bottom of the screen. . Ctrl+G If you forget what you are editing, pressing these keys displays the name of the file that you are editing and the current line that you are on at the bottom of the screen. It also displays the total number of lines in the file, the percentage of how far you are through the file, and the column number the cursor is on. This just helps you get your bearings after you ve stopped for a cup of coffee at 3 a.m. Moving Around the File Besides the few movement commands described earlier, there are other ways of moving around a vi file. To try these out, open a large file that you can t do much damage to. (Try copying /var/log/messages to /tmp and opening it in vi.) Here are some movement commands you can use: . Ctrl+F Page ahead, one page at a time. . Ctrl+B Page back, one page at a time. . Ctrl+D Page ahead one-half page at a time. . Ctrl+U Page back one-half page at a time. . G Go to the last line of the file. . 1G Go to the first line of the file. (Use any number to go to that line in the file.) Searching for Text To search for the next occurrence of text in the file, use either the slash (/) or the question mark (?) character. Follow the slash or question mark with a pattern (string of text) to search forward or backward, respectively, for that pattern. Within the search, you can also use metacharacters. Here are some examples: . /hello Searches forward for the word hello. . ?goodbye Searches backward for the word goodbye.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.