2. Create and Edit Text Files Part II – (LFCSA)

In part 1 we have learned about, how to create and edit files using vi and nano editor, but there is another weapon that we had to do so. And it is VIM editor and it is just VI improved version with some good text highlighting and such things that make it impressive so let’s begin with it.

Okay, first create a file using VIM.

Just type “vim” and following with the file name with extension.

[email protected]:~/Desktop/LinuxPractice# vim test.txt

Now you can see the vim editor opened and look at very left down a corner of the terminal and also you can see the file name with a tag “test.txt [New File]”. That’s it you have created the file using vim editor.

Now there are the couple of new features that a VIM editor comes with like append, newline, copy, paste, undo, redo. etc. Yeah….what’s new in that….but so far we are talking about these implementations on a terminal.

1. Insertion using “i”

Let’s insert something in the file, so for that, you need to press “i” to insert some characters in the editor. And you will be redirected from command mode to edit mode of vim.

2. Appending text using “a”

Now, if you need to append some characters in the file (make sure you are in command mode if not, press ESC), just move your cursor to where you need to append the text and press “a” and you can see the cursor moves one space forward and you’ll be able to append the text. Also, you can notice that automatically your vim editor is changed to “insert mode”.

3. NewLine using “o”

For instance, let’s suppose you are in command mode and suddenly you want to add a new line from where your cursor is. The solution is just press “o” and your cursor automatically moves to the new line and also vim changes to edit mode.

4. Copy using “y” and paste using “p”

For copying a line you need to first move the cursor to the line, which you want to copy (make sure you are in command mode) and then press “y” to “yank” or copy. To paste use “p” command.

So, far we have done many manipulations to text files and there are a lot more than you think. It’s not possible to write complete articles on that but you can yourself do that using “manual pages“. Just type “man” followed by the command name.

man sort

5. Searching Text using “/”

Open the text file in command mode and just hit “/” followed with the searching term.

Written by Anandesh

I am a #Linux lover and very much excited about technology and new thing. Love to #read_books. Curiosity is my best teacher. I am still☺️ understanding myself.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to install and use Git on Linux (Command Line)?

3. Use Input / Output Redirection / Compare Text Files / Compare Binary Files