Ubuntu 22.04 Command Line Editors
Please Select a Licence from the LICENCE_HEADERS page |
And place at top of your page |
If no Licence is Selected/Appended, Default will be CC0 Default Licence IF there is no Licence placed below this notice!
When you edit this page, you agree to release your contribution under the CC0 Licence LICENCE:
More information about the cc0 licence can be found here: You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. Licence: Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; moral rights retained by the original author(s) and/or performer(s); publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; rights protecting the extraction, dissemination, use and reuse of data in a Work; database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. |
Command Line Editors
A command line editor is a type of software program that allows users to create and edit text files directly from a command line interface. This means that instead of using a graphical user interface, users interact with the editor through a text-based interface.
Command line editors are often used by programmers and system administrators who need to work with text files in a terminal environment. They are particularly useful for tasks such as modifying configuration files, writing scripts, and editing code.
Some popular command line editors include Vi, Nano, and Emacs. Each editor has its own set of features and commands, and users often have strong preferences for which one they prefer to use.
One advantage of using a command line editor is that it allows for efficient editing of text files without the need for a separate program or application. Additionally, command line editors can be used over a network connection, which can be useful for remote administration and collaboration.
However, command line editors do require some familiarity with basic command line navigation and editing commands, which can be daunting for users who are not accustomed to working in a terminal environment. Nonetheless, mastering a command line editor can be a valuable skill for anyone who works with text files on a regular basis.
VI
vi is a text editor that is built into most Linux distributions. It is a command-line based editor that can be used to create and modify text files.
vi has two main modes:
- Command mode: This is the default mode when you open a file in "vi". In command mode, you can navigate around the file, make edits, and execute commands. You cannot enter text in this mode.
- Insert mode: In insert mode, you can enter text into the file. To enter insert mode, you need to switch from command mode to insert mode.
Here's how to switch between the two modes in "vi":
- To switch from command mode to insert mode, press the "i" key. This will allow you to start typing text into the file.
- To switch from insert mode back to command mode, press the "Esc" key.
While in command mode, you can use various commands to navigate around the file and perform various editing tasks, such as deleting or copying text. Here are some examples of commands you can use in command mode:
h
: Move the cursor left
j
: Move the cursor down
k
: Move the cursor up
l
: Move the cursor right
dd
: Delete the current line
yy
: Copy the current line
p
: Paste the last line that was copied or deleted
There are many more commands available in "vi". You can access a list of commands by typing :help
in command mode.
It's important to note that "vi" can be a bit confusing for new users, especially since it requires memorizing different commands to navigate and edit files. However, once you get the hang of it, "vi" can be a very powerful and efficient tool for editing text files.
nano
Nano is a simple, easy-to-use text editor that is available on most Linux distributions. It is designed to be user-friendly and intuitive, making it a good choice for beginners who are new to Linux.
Here are some examples of how to use Nano:
To open a file with Nano, type the following command in a terminal:
nano filename
This will open the file "filename" in the Nano editor.
To enter text in Nano, simply start typing. Text will appear at the cursor location.
To save changes to a file, press the Ctrl and O keys together. This will bring up the save prompt. Type in the name of the file you want to save and press "Enter".
To exit Nano, press the Ctrl and X keys together. If there are unsaved changes, Nano will prompt you to save them before exiting.
To copy text in Nano, use the Alt and 6 keys together to set a mark at the beginning of the text you want to copy, then move the cursor to the end of the text you want to copy. Press the Ctrl and K keys together to cut the text to the clipboard. Move the cursor to the location where you want to paste the text, and press the Ctrl and U keys together to paste the text.
To search for text in Nano, press the Ctrl and W keys together. This will bring up the search prompt. Type in the text you want to search for and press "Enter". Nano will search the file for the text and highlight the first occurrence.
To navigate through a file in Nano, use the arrow keys to move the cursor up, down, left, or right. Use the Page Up and Page Down keys to move the cursor up or down one page at a time.
Nano is a great option for users who prefer a simple, easy-to-use text editor that doesn't require memorizing complicated commands.
Emacs
Emacs is a text editor that is popular among programmers and developers. It is a powerful, customizable editor that is available on most operating systems, including Linux, macOS, and Windows.
Here are some basic commands that you can use to get started with Emacs:
To open a file with Emacs, type the following command in a terminal:
emacs filename
This will open the file "filename" in the Emacs editor.
To enter text in Emacs, simply start typing. Text will appear at the cursor location.
To save changes to a file, press the Ctrl and X keys together, followed by the Ctrl and S keys. This will save the changes to the file.
To exit Emacs, press the Ctrl and X keys together, followed by the Ctrl and C keys. If there are unsaved changes, Emacs will prompt you to save them before exiting.
To copy text in Emacs, use the Alt and W keys together to mark the beginning of the text you want to copy, then move the cursor to the end of the text you want to copy. Press the Alt and W keys together to copy the text to the clipboard. Move the cursor to the location where you want to paste the text, and press the Ctrl and Y keys together to paste the text.
To search for text in Emacs, press the Ctrl and S keys together. This will bring up the search prompt. Type in the text you want to search for and press "Enter". Emacs will search the file for the text and highlight the first occurrence.
To navigate through a file in Emacs, use the arrow keys to move the cursor up, down, left, or right. Use the PgUp and PgDn keys to move the cursor up or down one page at a time.
Emacs also has a wide range of features and customization options, making it a powerful tool for developers. Some popular features include syntax highlighting, code completion, and version control integration.
To learn more about Emacs and its advanced features, you can check out the official documentation and online tutorials.
Set $EDITOR
In Linux and other Unix-like operating systems, the EDITOR environment variable is used to specify the default text editor that should be used when opening and editing files from the command line.
The set EDITOR=nano command is used to set the EDITOR environment variable to the nano text editor. This means that any command or program that requires a text editor to be opened, such as git commit, will now use nano as the default editor instead of the previously set default.
The nano editor is a simple, easy-to-use text editor that is designed to be user-friendly and intuitive, making it a good choice for beginners who are new to Linux.
Setting the EDITOR environment variable to nano can be useful for users who prefer to use nano as their default text editor, or for users who are not familiar with other text editors like vi or emacs.
To make the EDITOR environment variable persist across terminal sessions, you can add the set EDITOR=nano command to your shell startup file, such as .bashrc or .zshrc, depending on which shell you are using.
To see if EDITOR as already be assigned:
echo $EDITOR
To set environment variable:
set EDITOR=nano
To unset use:
unset EDITOR