Skip to content

Latest commit

 

History

History
145 lines (122 loc) · 3.83 KB

files.adoc

File metadata and controls

145 lines (122 loc) · 3.83 KB

Writing and editing files

There are several ways to write and edit files. The most commonly used text editors are vi, emacs and gedit.

Gedit

Gedit is a text editor with graphical user interface. To create a new file in the current folder just call gedit with the name of the file:

gedit file.txt

When you are done, save the file (by pressing Ctrl+S or by selecting File  Save) and close Gedit.

Vi

Vi is a text editor with a command mode interface. See this article for a beginner’s guide.

To create a new file in the current folder just call vi with the name of the file:

vi file.txt

Vi has several modes which are specified in the bottom part of screen. When you just open the editor you cannot write on the file, because it is the command mode. To start writing, press i, and you will notice that the status in the bottom of the screen changed to INSERT. Now you can paste the text by right-click with the mouse and paste, or by pressing SHIFT+Insert. To go back to command mode press ESC. To save, make sure you are in command mode and type:

:wq

To undo, press u when you are in command mode.

GNU nano

GNU nano is a text editor for Unix-like operating systems using a command line interface. The following sections describe the commands used for opening, editing and saving files using nano.

File Control

 nano main.nf

Open or create the file main.nf

 kbd:[Ctr+o] kbd:[Enter]

Save changes

 kbd:[Ctrl+x]

Quit

Navigating through file contents

 kbd:[Ctrl+a]

Move to the beginning of the current line

 kbd:[Ctrl+e]

Move to the end of the current line

 kbd:[Ctrl+v]

Move down one page

 kbd:[Ctrl+y]

Move up one page

 kbd:[Ctrl+w] kbd:[Ctrl+y]

Go to the beginning of the file

 kbd:[Ctrl+w] kbd:[Ctrl+v]

Go to the end of the file

Copy and Paste

 kbd:[Ctrl+c] (Mac kbd:[Cmd+c])

Copy the current selection to the clipboard

 kbd:[Ctrl+v] (Mac kbd:[Cmd+c])

Paste the contents from the clipboard at the current cursor position

 kbd:[Ctrl+k]

Cut from the current cursor position to the end of the current line

 kbd:[Ctrl+d]

Delete the character at the current cursor position

Search and Replace

 kbd:[Ctrl+w]

Search for a target string