[Text editor nano, vim, gedit, file usage, and version update issues under ubuntu system]

Text Editor Summary

Under Ubuntu, there are many text editors to choose from, each with its own unique features and uses. Here are some common text editors:
Gedit: This is Ubuntu’s default text editor. It is simple to use and suitable for basic text editing tasks.
Installation method: Gedit is usually pre-installed in Ubuntu systems. If you need to make sure it’s installed, you can run sudo apt-get install gedit in the terminal.

Nano: Nano is a terminal text editor suitable for editing files from the command line. Its interface is relatively friendly and suitable for novices to use.
Installation method: Nano is usually pre-installed in Ubuntu systems. If installation is required, run sudo apt-get install nano.

Vim: Vim is a highly customizable terminal text editor with very powerful features and shortcut keys. But for newbies, the learning curve can be steep.
Installation method: Vim is usually not pre-installed in the system, you can run sudo apt-get install vim to install it.

Emacs: Emacs is a powerful text editor that provides rich plug-ins and extension functions. It has some complicated shortcut keys, but once mastered, it can make editing more efficient.
Installation method: Emacs is usually not pre-installed in the system, you can run sudo apt-get install emacs to install it.

Sublime Text: Sublime Text is a cross-platform commercial text editor that provides many advanced features and plug-in support. Its user interface is very modern and intuitive.
Installation method: You can download and install it from the official website of Sublime Text.

Visual Studio Code (VS Code): VS Code is a free and open source code editor developed by Microsoft that has rich features and a powerful extension ecosystem.
Installation method: You can download and install from the official website of VS Code.

Gedit

Gedit (GNU Editor) is a lightweight text editor that is part of the GNOME desktop environment. It provides an intuitive user interface suitable for basic text editing and code writing tasks. Gedit supports syntax highlighting, plug-in extensions, file comparison and other basic editing functions.
It can be installed by following these steps:
Open a terminal.
Enter the following command and press Enter:

sudo apt-get update
sudo apt-get install gedit

How to open, edit and save files:

Open Gedit:
Via the application menu: Find the “Accessories” or “Utilities” category in the menu and you should be able to find the Gedit icon. Click on it to open the editor.
Through the terminal: Type gedit in the terminal and press Enter.

Edit file:
Open a file: In Gedit, you can open a file through the “File” option in the menu bar or by using the shortcut key (Ctrl + O).
Edit files: In the editor, you can freely edit text. Gedit supports syntax highlighting, which intelligently highlights code based on file type.

save document:
Save a file: Click the File option in the menu bar and select Save, or use the shortcut key (Ctrl + S) to save the file.
Save As: If you want to save the file under a different file name or in a different location, select File > Save As.

Exit Gedit:
Close the file: If there are no unsaved changes to the file, you can click the close button (usually an ‘X’) in the upper right corner of the editor to close the current file tab.
Close Gedit: If you want to exit the entire Gedit editor, you can click the “File” option in the menu bar and select “Quit”, or use the shortcut key (Ctrl + Q) directly.
Version switching problem:

In Linux systems, if you have multiple versions of Gedit installed and want to switch between them, you can use the update-alternatives command to do so. The update-alternatives command is used to manage alternatives in the system and can be used to select the default version of the software installed in the system.
Check the installed Gedit version:

update-alternatives --list gedit

This will display the paths to all installed versions of Gedit on your system.
Switch Gedit version:

sudo update-alternatives --config gedit

After running the above command, the system will list all installed Gedit versions and you will be prompted to choose a default version. Enter the corresponding number and press the Enter key to select the default Gedit version.

sudo gedit file path

nano

nano is a simple and easy-to-use text editor, often used for text editing in terminal environments. The friendly interface and basic editing functions are suitable for beginners and users who need to edit text quickly. The following is an introduction to nano, including how to install, open, edit files, save and exit and other basic operations.

In most Linux distributions, nano comes pre-installed. If nano is not installed on your system, you can install it using a package manager. Here are some common package manager commands:

Debian/Ubuntu:

sudo apt-get update
sudo apt-get install nano

Red Hat/CentOS:

sudo yum install nano

Fedora:

 sudo dnf install nano

open a file

To open a file, just enter the following command in the terminal, followed by the file name:

nano filename

For example, if you want to edit a file named example.txt, you would enter:

nano example.txt

Edit file

After opening the file, you will see nano’s editing interface. You can use the keyboard for text editing. Commonly used editing commands are as follows:

 Move the cursor: Use the direction keys to move up, down, left, and right.
    Insert text: Just start typing.
    Cut, copy, paste: Use Ctrl + K to cut a line, Ctrl + U to paste, Ctrl + Shift + ^ to copy.
    Save the file: Use Ctrl + O and then press Enter to save the file.
    Exit Nano: Use Ctrl + X.

Save and exit

After editing, press Ctrl + O and then Enter to save the file. Then press Ctrl + X to exit the nano editor.

Type man nano in the terminal to view nano’s man page.

vim

Features of Vim:

Mode switching: Vim has different modes, including normal mode, insert mode, command line mode, etc. In normal mode, you can move the cursor, copy, paste, etc. In insert mode, you can enter text. In command line mode, you can execute commands.
Powerful editing functions: Vim provides rich text editing functions, including find and replace, copy and paste, undo and redo, macro recording, etc.
Customizability: Vim is very customizable, and you can configure various plug-ins and shortcut key mappings according to your needs.
Syntax highlighting: Vim can display syntax highlighting based on file type, making the code more readable.
Plug-in support: Vim has a powerful plug-in system. Users can install various plug-ins as needed to extend Vim’s functions.
Basic usage guide for Vim:
Open a file: Enter the following command in the terminal to open a file.

vim filename

Save and exit:
In normal mode, enter :w to save the file.
Enter :q to exit Vim.
Enter :wq to save and exit.
Insert text:
In normal mode, press i to enter insert mode and start typing text.
Press the Esc key to return to normal mode.
Move the cursor: In normal mode, use the arrow keys or the h, j, k, l keys to move the cursor.
Delete text:
The x key deletes the character at the cursor position.
dd deletes the current line.
D Delete the content from the cursor position to the end of the line.

Undo and redo:
Undo: In normal mode, press u.
To redo: In normal mode, press Ctrl + r keys.
Find and replace:
Search: In normal mode, press the / key, enter what you want to find, and press the Enter key.
Replacement: In normal mode, enter :%s/old_text/new_text/g to replace all old_text in the document with new_text.
,

Press the ESC key on the keyboard. After pressing the ESC key, the word “Insert” in the lower corner of the terminal will disappear. At this time, you can no longer enter any text. If you want to enter text again, press the “a” key to re-enter. to input mode. As the name suggests, the command mode is the mode for inputting commands. These commands are commands to control text. We classify these commands as follows:

1. Move cursor command:

h (or left arrow key) moves the cursor one character to the left.
l (or right arrow key) moves the cursor one character to the right.
j (or down arrow key) moves the cursor down one line.
k (or up arrow key) moves the cursor up one line.
nG moves the cursor to the beginning of line n.
n + moves the cursor down n lines.
n- Move the cursor up n lines.
2. Screen scrolling command

Ctrl + f turns the screen down one page, equivalent to the next page.
Ctrl + b turns the screen up one page, equivalent to the previous page.
3. Copy, delete and paste instructions

cc deletes the entire line and modifies the entire line.
dd deletes the line and does not provide modification functions.
ndd deletes the current line n lines down.
x Delete the character where the cursor is.
X deletes the character before the cursor.
nyy copies the current line and n lines below it.
p Pastes the recently copied content.