官术网_书友最值得收藏!

Creating, editing, and saving files on the BeagleBone Black

Now that you can log in and move easily between directories and see which files are in your directories, you'll want to be able to edit those files. To do this, you'll need a program that allows you to edit the characters in a file. If you are used to working in Microsoft Windows, you probably have used a program like Microsoft Notepad, Wordpad, or Word to do this. As you might imagine, these are not available in Linux. There are several choices, all of which are free. I am going to show you how to use an editor program called Emacs. Other possibilities are programs like nano, vi, vim, and gedit. Programmers have strong preferences about which editor to use, so if you already have a favorite, you can skip this section.

Prepare for lift off

If you want to use Emacs, then download and install Emacs by typing sudo apt-get install emacs.

Engage thrusters

Once installed, you can run Emacs simply by typing emacs filename, where filename is the name of the file you want to edit. If the file does not exist, then Emacs will create the file. Here is what you will see if you type emacs example.py at the prompt:

Engage thrusters

Notice that unlike Windows, Linux doesn't automatically assign file extensions; it is up to us to specify what kind of file we want to create. Notice that Emacs has indicated, in the lower left, that you have opened a new file. Now, if you are using Emacs in the Xfce windows interface, either because you have a monitor, keyboard, and mouse hooked up or are running vncserver, you can use the mouse in much the same way that you use the mouse in the Microsoft world.

However, if you are running Emacs from SSH, you won't have the mouse available, so you'll need to move around the file using the cursor keys. You'll also have to use some keystroke commands to save your file, as well as accomplish a number of other tasks you would normally use the mouse to select. For example, when you are ready to save the file you'll use Ctrl + X then Ctrl +S, and that will save the file under the current filename. When you want to quit Emacs you'll use Ctrl + X then Ctrl + C. This will stop Emacs and return you to the command prompt. If you are going to use Emacs inside of Emacs, here are a number of keystroke commands you might find useful:

Objective complete – mini debriefing

Now that you have the capability to edit files, in the next section you'll use this capability to create programs.

主站蜘蛛池模板: 威海市| 肇庆市| 乌恰县| 即墨市| 苍山县| 德保县| 信丰县| 东源县| 青冈县| 大同县| 兴宁市| 虹口区| 丹江口市| 三原县| 喀什市| 岑巩县| 连州市| 株洲县| 霍山县| 马公市| 清新县| 郧西县| 铜山县| 济阳县| 全椒县| 海安县| 柳林县| 息烽县| 讷河市| 承德市| 西充县| 阳春市| 通化市| 亚东县| 湖北省| 怀安县| 名山县| 芦溪县| 霍城县| 鲁山县| 皋兰县|