Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this movie, we are going to take a look at the text editors that are available for Unix. If you remember back to our discussion about the history of Unix, Unix has been around a really long time and it pre- dates all of the graphical user interfaces in the modern day text editors that we are used to. So what did they use in those really early days, when Unix had first been invented? Well, they used a text editor called ed, for edit text, and it was really simple and is not at all user friendly. So it's not something that we even want to think about now, but in the early days that was the very first thing. Well, then over time people said, "It would be great if we had something that was more of a visual text editor. We can see the page that we are working with." And so they came with something called vi.
That's visual editing mode and later that was improved and replaced with vim. So you can still type vi, but chances are it will take you into vim, because vim has pretty much replaced it. It's just vi with some improvements. vim is very much still in use. There are a lot of Unix users that love it. The reason why they love it is because your fingers get to stay in the center of your keyboard. Its' a modal editor, so you switch modes. You hit a special key. It switches you into a different mode and then now your keystrokes on those main letter keys do something different, let's say move your cursor around.
Then you switch into editing mode. Now your keystrokes are actually editing the text. Then you switch back out of editing mode into move the cursor around mode and so on. So they like it because their fingers really stay in the center of the keyboard and it's very fast. It's tough for beginners, because you have get used to switching between these different modes and sometimes you might hit a key thinking you are going to get the letter t, but in fact you have actually triggered a different action because you were in a different mode. Another very popular editor in the Unix community is Emacs. It stands for editor macros.
Its power really comes from the fact that it has lots and lots of macros that allow you to do complex task, so it really allows you to do all sort of things besides just simply edit the text. You can think of it as being a Swiss army knife. Again not that great for beginners because you have to learn what all these macros are. It has all these power there but it requires you to really learn how it works, the same way that vim does. A better choice for beginners is pico which later became nano. pico stands for pine composer. pine was a very simple email program that will allow you to send emails from the command line.
So you would compose your simple email message using this pine composer and then send the message up, very user friendly. pico became an editor on its own separate from the mail program. Later that was improved and replaced with nano and nano is a little bit of take off of pico because pico can be prefixed to a size or a number. nano is 1000 times larger than pico and nano is now what we have and what we will be using. If you type pico on your Mac, you will just get put into nano. It has completely replaced it. It has basic features. It is very easy to use.
So the easiest way to use nano is just to type the nano command. nano boom! Now I am inside nano. This is my text editor. I can use the Return key to go down, use the arrow key to go up, and I can just type. Hello! Whenever you want to exit the program you will see at the bottom it gives you hints about things it's going to do. You see that there is a little up arrow there. That's the equivalent of the Ctrl key. So Ctrl+X, for example, will allow me to exist. Ctrl+G would get help and show me lots of help information.
Let's go ahead and exit for now. Ctrl+X. It comes up and says Save modified buffer? So do I want to save the changes that I made. That's what it's asking. It's the same kind of pop-up window that you get if you try and close a Microsoft Word file without saving your changes first. So do we want to save these changes. If I say No, just type it in, you will see I come right back here. If I had said Yes, then it would prompt me for a file name. There is another way that you can use nano. We can use nano on an existing file or nano on a new file. If I type nano followed by newfile.txt then it will go ahead and have that name waiting for me when I am done.
Let's go ahead and try it a real quick. nano newfile and This is a new file and then we will do Ctrl+X, save changes, this time I am going to hit Y for yes, and it says File Name to Write to. Do you want to write it to newfile.txt? So it has already got the name that I gave it there waiting. I just hit the Return key and there I am. Now if you do ls -la, you will see that that new file is there. You can also use it on an existing file. Let's take the somefile.txt that we created before. W can just do Nano somefile.txt. There we are, there are no lines in there but you can see that I am inside this file and I will just type changes, and then Ctr+X, Y, voila! There I am out of there and now we can see that that file actually has those changes. nano somefile. There is my changes inside there.
Now as I said before, you just use the arrow keys to move around. You can hit the Delete key to backspace, to erase thing,s and then type replacement characters just at the cursor, exactly like you would expect. The other main features that you are going to use from this are all down here at the bottom. You can search through a document using the W, where is, and that will search the document for the next occurrence of whatever it is you are looking for. Previous page and next page. If you have a long document, you can use the Ctrl key with either Y or V to go forwards and backwards and then you might also frequently use K to cut text.
So you can cut text sort of to cut and then uncut. It is the same thing is paste. We will cut a line of text and then you will paste it somewhere else. There are lots and lots of other options. You can use the help menu to find out a lot of things that you can do here. You can also go to http://www. nanoeditor.org and that will also give you more information there. So www.nano-editor.org and it's sort of a user's manual for all the things that you can do with nano. But this is really what we are going to be using for. It's just these real basics,. Just sort of open it up, edit some text and exit back out of it.
Now you may be wondering, well, what about other text editors things that you are most familiar with, can I use those? Absolutely. If you have something like TextMate, things that just write plain text files, those are fine to use. Something like Microsoft Word though, you would not want to use because Microsoft Word saves in its file not just text but also its formatting information that has to be interpreted by Microsoft Word. So we couldn't open it up in nano or we would see all sorts of characters that don't mean anything to nano, which do have a special meaning to Microsoft Word. So plain text editors are fine, but using something like Microsoft Word, you want to make sure that you save your files as plain text.
Since we are really trying to focus on Unix, let's try and stay inside the command line and use the tools that Unix gives us.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.