国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home System Tutorial LINUX Vim Text Editor Getting Started Guide

Vim Text Editor Getting Started Guide

Jan 02, 2024 pm 04:58 PM
linux linux tutorial Red Hat linux system linux command linux certification red hat linux linux video

Vim 文本編輯器 入門指南

For a programmer, choosing a text editor is a very important thing. Because there are many differences between different editors: graphical interface or non-graphical interface, different shortcut keys, different programming language support, different plug-ins and custom settings, etc. My advice is not to search for the best editor, but to choose the one that best suits your habits and best suits your tasks. If you plan to work in a group, it's best to choose the same editor as your colleagues. This way, if you encounter problems during use, you can go to them for help.

This is exactly why I started using Vim a few years ago. Generally speaking, Vim is placed in opposition to the legendary Emacs. I admit I know very little about Emacs, but what you need to know about both is that they are both deeply customizable and can be very confusing at first. This tutorial won't cover everything there is to know about Vim, but it will cover the basics so you can get it right from the start, and then show you some tips that will (hopefully) give you the ability to explore on your own. study.

The word Vim comes from "Vi IMproved". Vi is a non-graphical text editor widely installed on Unix systems, and it is also installed by default on Linux systems. Vim is an enhanced version of this original editor, but unlike Vi, not every distribution has it installed by default.

Install

You can use the following command to install Vim in Ubuntu:

sudo apt-get install vim

If you are already interested in certain plug-ins, use the following command:

sudo apt-cache search vim

This command will output you a long list of packages related to Vim. Among these, there are tools for different programming languages, plug-in managers, and so on.

In this series of tutorials, I will use the latest version of Vim (7.3.154, LCTT Annotation: the latest version is now 8.0) on Ubuntu. Of course you can use any other version.

warm up

Enter the vim command in the terminal, and you will see a great welcome interface.

Vim 文本編輯器 入門指南

(LCTT translation annotation: Did you see the line "Help poor children in Uganda!" in the welcome interface?)

If you've never used Vi or Vim before, chances are you don't even know how to exit it... Yes, that's true. Any shortcut keys you commonly use in Vim will lose their original effects. (LCTT translation annotation: There is a joke circulating on the Internet - "How to create garbled code" and "Let novices exit vi")

First, use any imperative function like Save () or Exit ( ), you must first enter a colon (:). Saving is :w and exiting is :q. If you want to exit without saving the file, use the force exit command :q!. The great thing about Vim is that you don't need to enter each command separately. In other words, if you want to save and exit, you can just use :wq.

Now, we exit Vim and open a text file. To do this, just add the name of the file you want to edit after the command:

vim [文本文件名]

Vim 文本編輯器 入門指南

Generally speaking, when you open a text file, you will be in view mode. This makes Vim unique and initially confusing. Vim mainly consists of two modes: viewing mode and editing mode. View mode is used to view content and use some commands. To enter edit mode, just press the i key to insert () or the a key to Add to(). To return to view mode or perform command function operations, press the Escape key. The difference between inserting () and adding () is just that you want Enter edit mode and enter text before or after the cursor position. To fully understand, you should try it yourself. My suggestion: use to add () only at the end of the line, and to insert (## at other times #).

(LCTT Translation: The original text of "view mode" in this paragraph is "visual mode", which is suspected to be "view mode". In this mode, text can be viewed but cannot be edited; while "visual mode" is editing mode. One, you can press the

v key to enter, and then you can use the direction keys to select starting from the current cursor position, and it will be displayed with a reversed visual effect. Normally, you can press y after selection. Copy, press d to cut, etc. In addition, the author's terminology is not standard. According to Vim's own terminology, the so-called "view mode" here should be called "normal mode" ", "Edit mode" should be called "Insert mode", but the meaning is the same.)

To move the cursor within text, you can usually use the arrow keys on the keyboard, which work in both view mode and edit mode. However, a true purist will tell you to use the keys

h for left, j for down, k for up, and i for Come right (in view mode) to move.

Now that you understand how to control Vim simply, let's go a little deeper.

Some simple commands Now that you are familiar with switching between normal mode and insert mode, here are some commands you can use in normal mode:

  • x: Delete a character
  • u: Undo an operation (equivalent to Ctrl z)
  • dd: Delete a line of content
  • dw: Delete a word
  • yy: Copy a line of content
  • yw: Copy a word
  • p: Paste a previously deleted or copied line or word
  • e: Jump to the next word (LCTT translation annotation: end of word) (faster than simply using the arrow keys)
  • r: Replace a letter (press r, release, then press new letter)

Of course there is more than this, but these are enough for now. If you master all of the above, you will be able to use Vim smoothly.

For those who want to know more, I will mention a few more. You can add a value before any of these commands and the command will be repeated the corresponding number of times. For example, 5x will delete 5 consecutive letters on the current line, while 3p will paste 3 times.

Advanced commands

Finally, as an encouragement and example for you to continue exploring, here are several advanced and commonly used commands:

  • /Searched content: Search for specific content in the text
  • :sp text file name: Split the screen into upper and lower halves horizontally, and the new file is displayed in the other half. If you want to switch focus on both sides, you can use the Ctrl w ??shortcut key.
    Vim 文本編輯器 入門指南
  • :vsp text file name: Same as above, but split the screen vertically
  • Ctrl Shift C and Ctrl Shift V: Copy and paste text in Terminal
  • :! Command name: Run terminal commands outside Vim in Vim and send them directly to the shell. For example, :! ls will display the files in your current directory without exiting the editor.
    Vim 文本編輯器 入門指南
in conclusion

I think you should be ready enough to start using Vim now. You can also use interactive tutorials to learn more by installing various plugins, editing the ~.vimrc file, or entering the vimtutor command in the shell.

If you have any other Vim commands you’d like to share, please let us know in the comments.


The above is the detailed content of Vim Text Editor Getting Started Guide. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How to install Linux alongside Windows (dual boot)? How to install Linux alongside Windows (dual boot)? Jun 18, 2025 am 12:19 AM

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

How to enable the EPEL (Extra Packages for Enterprise Linux) repository? How to enable the EPEL (Extra Packages for Enterprise Linux) repository? Jun 17, 2025 am 09:15 AM

The key to enabling EPEL repository is to select the correct installation method according to the system version. First, confirm the system type and version, and use the command cat/etc/os-release to obtain information; second, enable EPEL through dnfinstallepel-release on CentOS/RockyLinux, and the 8 and 9 version commands are the same; third, you need to manually download the corresponding version of the .repo file and install it on RHEL; fourth, you can re-import the GPG key when encountering problems. Note that the old version may not be supported, and you can also consider enabling epel-next to obtain the test package. After completing the above steps, use dnfrepolist to verify that the EPEL repository is successfully added.

How to choose a Linux distro for a beginner? How to choose a Linux distro for a beginner? Jun 19, 2025 am 12:09 AM

Newbie users should first clarify their usage requirements when choosing a Linux distribution. 1. Choose Ubuntu or LinuxMint for daily use; programming and development are suitable for Manjaro or Fedora; use Lubuntu and other lightweight systems for old devices; recommend CentOSStream or Debian to learn the underlying principles. 2. Stability is preferred for UbuntuLTS or Debian; you can choose Arch or Manjaro to pursue new features. 3. In terms of community support, Ubuntu and LinuxMint are rich in resources, and Arch documents are technically oriented. 4. In terms of installation difficulty, Ubuntu and LinuxMint are relatively simple, and Arch is suitable for those with basic needs. It is recommended to try it first and then decide.

How to add a new disk to Linux How to add a new disk to Linux Jun 27, 2025 am 12:15 AM

The steps to add a new hard disk to the Linux system are as follows: 1. Confirm that the hard disk is recognized and use lsblk or fdisk-l to check; 2. Use fdisk or parted partitions, such as fdisk/dev/sdb and create and save; 3. Format the partition to a file system, such as mkfs.ext4/dev/sdb1; 4. Use the mount command for temporary mounts, such as mount/dev/sdb1/mnt/data; 5. Modify /etc/fstab to achieve automatic mount on the computer, and test the mount first to ensure correctness. Be sure to confirm data security before operation to avoid hardware connection problems.

Fixed the failure to upload files in Windows Google Chrome Fixed the failure to upload files in Windows Google Chrome Jul 08, 2025 pm 02:33 PM

Have problems uploading files in Google Chrome? This may be annoying, right? Whether you are attaching documents to emails, sharing images on social media, or submitting important files for work or school, a smooth file upload process is crucial. So, it can be frustrating if your file uploads continue to fail in Chrome on Windows PC. If you're not ready to give up your favorite browser, here are some tips for fixes that can't upload files on Windows Google Chrome 1. Start with Universal Repair Before we learn about any advanced troubleshooting tips, it's best to try some of the basic solutions mentioned below. Troubleshooting Internet connection issues: Internet connection

Where are system logs located in Linux? Where are system logs located in Linux? Jun 24, 2025 am 12:15 AM

Logs in Linux systems are usually stored in the /var/log directory, which contains a variety of key log files, such as syslog or messages (record system logs), auth.log (record authentication events), kern.log (record kernel messages), dpkg.log or yum.log (record package operations), boot.log (record startup information); log content can be viewed through cat, tail-f or journalctl commands; application logs are often located in subdirectories under /var/log, such as Apache's apache2 or httpd directory, MySQL log files, etc.; at the same time, it is necessary to note that log permissions usually require s

What is the sudo command and when should I use it? What is the sudo command and when should I use it? Jul 02, 2025 am 12:20 AM

sudo stands for "substituteuserdo" or "superuserdo", allowing users to run commands with permissions of other users (usually root). Its core uses include: 1. Perform system-level operations such as installing software or editing system files; 2. Accessing protected directories or logs; 3. Manage services such as restarting nginx; 4. Modify global settings such as /etc/hosts. When using it, the system will check the /etc/sudoers configuration and verify the user password, provide temporary permissions instead of continuously logging in as root, ensuring security. Best practices include: only when necessary, avoid blindly executing network commands, editing sudoers files with visudo, and considering continuous operations.

How to manage groups on Linux How to manage groups on Linux Jul 06, 2025 am 12:02 AM

To manage Linux user groups, you need to master the operation of viewing, creating, deleting, modifying, and user attribute adjustment. To view user group information, you can use cat/etc/group or getentgroup, use groups [username] or id [username] to view the group to which the user belongs; use groupadd to create a group, and use groupdel to specify the GID; use groupdel to delete empty groups; use usermod-aG to add users to the group, and use usermod-g to modify the main group; use usermod-g to remove users from the group by editing /etc/group or using the vigr command; use groupmod-n (change name) or groupmod-g (change GID) to modify group properties, and remember to update the permissions of relevant files.

See all articles