VIM is a very useful and versatile editor for Linux. This is how to use it to its full potential. Some great VIM tricks to help for a Linux user or programmer.
To read the output of a command into a text file, use the :r command in the command mode, and then a Linux command.
:r ls -hula |
This will print the output of the command into a text file.
To use the sudo command, do it like this.
:r !sudo fdisk -l /dev/sdb |
This will put the output of the command into the text file.
To read a text file to the existing buffer, use this command in command mode.
:r love.cpp |
Then, the text file will be printed in the buffer.
3 #include <stdio.h> 4 5 int main (void) { 6 int i; 7 i = 0; 8 while (i < 9) { 9 printf("Eternal love to Athena.\n"); 10 i++; 11 } 12 return 0; 13 } |
Very nice .vmrc file for the Linux user.
https://securitronlinux.com/uncategorized/my-nice-vimrc-file/.
To open a file at a certain line, start it like this: vim +567 file.txt
. This will open the file file.txt on line 567.
Open VIM like this, if you wish to open a text file at the first occurrence of the word “mplayer”
4.4 Wed Jan 22 jason@Yog-Sothoth 0: $ vim macintosh.txt +/mplayer |
Very useful infographics and e-books to help learn the VIM editor.
https://securitronlinux.com/bejiitaswrath/very-useful-vim-tutorial-pdf/.