Vi 速查手册(摘自wks.uts.ohio-state.edu)

博客围绕vi编辑器展开,提供了vi的快速参考指南相关内容,属于信息技术中开发工具领域。
原文: http://wks.uts.ohio-state.edu/unix_course/intro-134.html ( http://wks.uts.ohio-state.edu/unix_course/)
作者:wks.uts.ohio-state.edu
[Next] [Previous] [Up] [Top] [Contents]

CHAPTER 10 Editors

10.3 vi Quick Reference Guide


All commands in vi are preceded by pressing the escape key. Each time a different command is to be entered, the escape key needs to be used. Except where indicated, vi is case sensitive.
Cursor Movement Commands:
(n) indicates a number, and is optional
(n)h left (n) space(s)
(n)j down (n) space(s)
(n)k up (n) space(s)
(n)l right (n) space(s)
(The arrow keys usually work also)
^F forward one screen
^B back one screen
^D down half screen
^U up half screen
(^ indicates control key; case does not matter)
H beginning of top line of screen
M beginning of middle line of screen
L beginning of last line of screen
G beginning of last line of file
(n)G move to beginning of line (n)
0 (zero) beginning of line
$ end of line
(n)w forward (n) word(s)
(n)b back (n) word(s)
e end of word
     
     
Inserting Text:
i insert text before the cursor
a append text after the cursor (does not overwrite other text)
I insert text at the beginning of the line
A append text to the end of the line
r replace the character under the cursor with the next character typed
R Overwrite characters until the end of the line (or until escape is pressed to change command)
o (alpha o) open new line after the current line to type text
O (alpha O) open new line before the current line to type text
Deleting Text:
dd deletes current line
(n)dd deletes (n) line(s)
(n)dw deletes (n) word(s)
D deletes from cursor to end of line
x deletes current character
(n)x deletes (n) character(s)
X deletes previous character
Change Commands:
(n)cc changes (n) characters on line(s) until end of the line (or until escape is pressed)
cw changes characters of word until end of the word (or until escape is pressed)
(n)cw changes characters of the next (n) words
c$ changes text to the end of the line
ct(x) changes text to the letter (x)
C changes remaining text on the current line (until stopped by escape key)
~ changes the case of the current character
J joins the current line and the next line
u undo the last command just done on this line
. repeats last change
s substitutes text for current character
S substitutes text for current line
:s substitutes new word(s) for old
:<line nos effected> s/old/new/g
& repeats last substitution (:s) command.
(n)yy yanks (n) lines to buffer
y(n)w yanks (n) words to buffer
p puts yanked or deleted text after cursor
P puts yanked or deleted text before cursor
File Manipulation:
:w (file) writes changes to file (default is current file)
:wq   writes changes to current file and quits edit session
:w! (file) overwrites file (default is current file)
:q   quits edit session w/no changes made
:q!   quits edit session and discards changes
:n   edits next file in argument list
:f (name) changes name of current file to (name)
:r (file) reads contents of file into current edit at the current cursor position (insert a file)
:!(command) shell escape
:r!(command) inserts result of shell command at cursor position
ZZ write changes to current file and exit


Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. Removing intermediate container abb03a1cb27a ---> 003b73213073 Step 9/23 : RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y --no-install-recommends nodejs ---> Running in b2b9be787ba2 2025-11-07 04:46:56 - =============================================================================== DEPRECATION WARNING =============================================================================== Node.js 18.x is no longer actively supported! You will not receive security or critical stability updates for this version. You should migrate to a supported version of Node.js as soon as possible. Please see https://nodesource.com/products/distributions for details about which version may be appropriate for you. The NodeSource Node.js distributions site contains information both about supported versions of Node.js and N|Solid supported Linux distributions. To learn more about usage, see: https://nodesource.com/products/distributions =============================================================================== Continuing in 10 seconds ... 2025-11-07 04:47:06 - Installing pre-requisites WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Reading package lists... Building dependency tree... Reading state information... 1 package can be upgraded. Run &#39;apt list --upgradable&#39; to see it. WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Reading package lists... Building dependency tree... Reading state information... ca-certificates is already the newest version (20230311ubuntu0.18.04.1). curl is already the newest version (7.58.0-2ubuntu3.24). The following additional packages will be installed: gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgsm pinentry-curses Suggested packages: parcimonie xloadimage dbus-user-session libpam-systemd pinentry-gnome3 scdaemon pinentry-doc The following NEW packages will be installed: apt-transport-https gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgsm pinentry-curses 0 upgraded, 10 newly installed, 0 to remove and 1 not upgraded. Need to get 1552 kB of archives. After this operation, 4525 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.17 [1692 B] Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg-l10n all 2.2.4-1ubuntu1.6 [50.1 kB] Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg-utils amd64 2.2.4-1ubuntu1.6 [128 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg amd64 2.2.4-1ubuntu1.6 [468 kB] Get:5 http://archive.ubuntu.com/ubuntu bionic/main amd64 pinentry-curses amd64 1.1.0-1 [35.8 kB] Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-agent amd64 2.2.4-1ubuntu1.6 [227 kB] Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-wks-client amd64 2.2.4-1ubuntu1.6 [91.8 kB] Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpg-wks-server amd64 2.2.4-1ubuntu1.6 [85.0 kB] Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gpgsm amd64 2.2.4-1ubuntu1.6 [215 kB] Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gnupg amd64 2.2.4-1ubuntu1.6 [249 kB] debconf: delaying package configuration, since apt-utils is not installed Fetched 1552 kB in 3s (472 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 26040 files and directories currently installed.) Preparing to unpack .../0-apt-transport-https_1.6.17_all.deb ... Unpacking apt-transport-https (1.6.17) ... Selecting previously unselected package gnupg-l10n. Preparing to unpack .../1-gnupg-l10n_2.2.4-1ubuntu1.6_all.deb ... Unpacking gnupg-l10n (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gnupg-utils. Preparing to unpack .../2-gnupg-utils_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gnupg-utils (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg. Preparing to unpack .../3-gpg_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg (2.2.4-1ubuntu1.6) ... Selecting previously unselected package pinentry-curses. Preparing to unpack .../4-pinentry-curses_1.1.0-1_amd64.deb ... Unpacking pinentry-curses (1.1.0-1) ... Selecting previously unselected package gpg-agent. Preparing to unpack .../5-gpg-agent_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-agent (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg-wks-client. Preparing to unpack .../6-gpg-wks-client_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-wks-client (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpg-wks-server. Preparing to unpack .../7-gpg-wks-server_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpg-wks-server (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gpgsm. Preparing to unpack .../8-gpgsm_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gpgsm (2.2.4-1ubuntu1.6) ... Selecting previously unselected package gnupg. Preparing to unpack .../9-gnupg_2.2.4-1ubuntu1.6_amd64.deb ... Unpacking gnupg (2.2.4-1ubuntu1.6) ... Setting up apt-transport-https (1.6.17) ... Setting up gnupg-l10n (2.2.4-1ubuntu1.6) ... Setting up gpgsm (2.2.4-1ubuntu1.6) ... Setting up gnupg-utils (2.2.4-1ubuntu1.6) ... Setting up pinentry-curses (1.1.0-1) ... Setting up gpg (2.2.4-1ubuntu1.6) ... Setting up gpg-agent (2.2.4-1ubuntu1.6) ... Setting up gpg-wks-server (2.2.4-1ubuntu1.6) ... Setting up gpg-wks-client (2.2.4-1ubuntu1.6) ... Setting up gnupg (2.2.4-1ubuntu1.6) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Get:5 https://deb.nodesource.com/node_18.x nodistro InRelease [12.1 kB] Get:6 https://deb.nodesource.com/node_18.x nodistro/main amd64 Packages [11.7 kB] Fetched 23.9 kB in 2s (13.3 kB/s) Reading package lists... Building dependency tree... Reading state information... 1 package can be upgraded. Run &#39;apt list --upgradable&#39; to see it. 2025-11-07 04:47:18 - Repository configured successfully. 2025-11-07 04:47:18 - To install Node.js, run: apt install nodejs -y 2025-11-07 04:47:18 - You can use N|solid Runtime as a node.js alternative 2025-11-07 04:47:18 - To install N|solid Runtime, run: apt install nsolid -y Reading package lists... Building dependency tree... Reading state information... Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: nodejs : Depends: libc6 (>= 2.28) but 2.27-3ubuntu1.6 is to be installed E: Unable to correct problems, you have held broken packages. The command &#39;/bin/sh -c curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y --no-install-recommends nodejs&#39; returned a non-zero code: 100
11-08
[02:28:27] ✅ 密码正确,开始部署... [02:28:27] 🚀 优化系统资源使用:启用最大线程与内存 [02:28:27] 🧠 检测到 CPU 核心数: 32 [02:28:27] 🔧 执行: 📦 安装 pigz(并行 gzip) (最长等待 120 秒) E: dpkg was interrupted, you must manually run &#39;sudo dpkg --configure -a&#39; to correct the problem. [02:28:27] ❌ 命令失败 (退出码 100): 📦 安装 pigz(并行 gzip) [02:28:27] ⚡ 已启用多线程加速: 7z + pigz [02:28:27] 🔍 正在检测系统兼容性... [02:28:27] ✅ 操作系统: Ubuntu 20.04 (focal) [02:28:27] 🟢 版本受支持 [02:28:27] ✅ CPU 架构: x86_64 [02:28:27] 🔧 正在清理 APT 锁文件和占用进程... Setting up cryptsetup (2:2.2.2-3ubuntu2.5) ... Setting up linux-headers-5.4.0-216-generic (5.4.0-216.236) ... Setting up bind9-libs:amd64 (1:9.18.30-0ubuntu0.20.04.2) ... Setting up grub2-common (2.04-1ubuntu26.17) ... Setting up iptables (1.8.4-3ubuntu2.1) ... Setting up python3-apt (2.0.1ubuntu0.20.04.1) ... Setting up libasn1-8-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up gpgsm (2.2.19-3ubuntu2.5) ... Setting up ltrace (0.7.3-6.1ubuntu1.1) ... Setting up libnss3:amd64 (2:3.98-0ubuntu0.20.04.2) ... Setting up linux-headers-generic (5.4.0.216.208) ... Setting up libmbim-proxy (1.26.2-1~ubuntu20.04.1) ... Setting up kmod (27-1ubuntu2.1) ... update-initramfs: deferring update (trigger activated) Setting up libgpgme11:amd64 (1.13.1-7ubuntu2.2) ... Setting up libhcrypto4-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up grub-pc-bin (2.04-1ubuntu26.17) ... Setting up fdisk (2.34-0.1ubuntu9.6) ... Setting up python3-apport (2.20.11-0ubuntu27.31) ... Setting up grub-pc (2.04-1ubuntu26.17) ... Sourcing file `/etc/default/grub&#39; Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg&#39; Sourcing file `/etc/default/grub.d/init-select.cfg&#39; Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-216-generic Found linux image: /boot/vmlinuz-5.4.0-110-generic Found initrd image: /boot/initrd.img-5.4.0-110-generic done Setting up unattended-upgrades (2.3ubuntu0.3) ... Setting up libwind0-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up python3-packaging (20.3-1) ... Setting up cryptsetup-run (2:2.2.2-3ubuntu2.5) ... Setting up python3-software-properties (0.99.9.12) ... Setting up python3-twisted (18.9.0-11ubuntu0.20.04.5) ... Setting up libpython3.8:amd64 (3.8.10-0ubuntu1~20.04.18) ... Setting up python3-requests (2.22.0-2ubuntu1.1) ... Setting up udev (245.4-4ubuntu3.24) ... update-initramfs: deferring update (trigger activated) Setting up sosreport (4.8.2-0ubuntu0~20.04.1) ... Setting up gpg-wks-server (2.2.19-3ubuntu2.5) ... Setting up kpartx (0.8.3-1ubuntu2.4) ... Setting up procps (2:3.3.16-1ubuntu2.4) ... Setting up initramfs-tools-core (0.136ubuntu6.8) ... Setting up bind9-host (1:9.18.30-0ubuntu0.20.04.2) ... Setting up ubuntu-pro-client (37.1ubuntu0~20.04) ... Setting up linux-image-5.4.0-216-generic (5.4.0-216.236) ... Setting up ubuntu-pro-client-l10n (37.1ubuntu0~20.04) ... Setting up initramfs-tools (0.136ubuntu6.8) ... update-initramfs: deferring update (trigger activated) Setting up linux-headers-virtual (5.4.0.216.208) ... Setting up grub-efi-amd64-signed (1.187.12~20.04+2.06-2ubuntu14.8) ... Installing grub to /boot/efi. Installing for x86_64-efi platform. grub-install: warning: EFI variables are not supported on this system.. Installation finished. No error reported. Setting up openssh-server (1:8.2p1-4ubuntu0.13) ... rescue-ssh.target is a disabled or a static unit, not starting it. Setting up libhx509-5-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up libqmi-glib5:amd64 (1.30.4-1~ubuntu20.04.1) ... Setting up landscape-common (23.02-0ubuntu1~20.04.4) ... Setting up shim-signed (1.40.10+15.8-0ubuntu1) ... update-alternatives: using /usr/lib/shim/shimx64.efi.signed.latest to provide /usr/lib/shim/shimx64.efi.signed (shimx64.efi.signed) in auto mode Installing grub to /boot/efi. Installing for x86_64-efi platform. grub-install: warning: EFI variables are not supported on this system.. Installation finished. No error reported. Setting up open-iscsi (2.0.874-7.1ubuntu6.5) ... grep: /lib/modules-load.d/open-iscsi.conf: No such file or directory Setting up software-properties-common (0.99.9.12) ... Setting up apport (2.20.11-0ubuntu27.31) ... Installing new version of config file /etc/init.d/apport ... apport-autoreport.service is a disabled or a static unit, not starting it. Setting up multipath-tools (0.8.3-1ubuntu2.4) ... Removing obsolete conffile /etc/init.d/multipath-tools ... Setting up ubuntu-advantage-tools (37.1ubuntu0~20.04) ... Removing obsolete conffile /etc/update-motd.d/88-esm-announce ... Removing obsolete conffile /etc/ubuntu-advantage/help_data.yaml ... Setting up bind9-dnsutils (1:9.18.30-0ubuntu0.20.04.2) ... Setting up linux-image-virtual (5.4.0.216.208) ... Setting up cryptsetup-initramfs (2:2.2.2-3ubuntu2.5) ... update-initramfs: deferring update (trigger activated) update-initramfs: deferring update (trigger activated) Setting up libkrb5-26-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up libqmi-proxy (1.30.4-1~ubuntu20.04.1) ... Setting up libheimntlm0-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up linux-virtual (5.4.0.216.208) ... Setting up libgssapi3-heimdal:amd64 (7.7.0+dfsg-1ubuntu1.4) ... Setting up modemmanager (1.18.6-1~ubuntu20.04.1) ... Installing new version of config file /etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf ... Setting up libldap-2.4-2:amd64 (2.4.49+dfsg-2ubuntu1.10) ... Setting up libcurl3-gnutls:amd64 (7.68.0-1ubuntu2.25) ... Setting up dirmngr (2.2.19-3ubuntu2.5) ... Setting up gpg-wks-client (2.2.19-3ubuntu2.5) ... Setting up libfwupd2:amd64 (1.7.9-1~20.04.3) ... Setting up gnupg (2.2.19-3ubuntu2.5) ... Setting up libfwupdplugin5:amd64 (1.7.9-1~20.04.3) ... Setting up fwupd (1.7.9-1~20.04.3) ... Installing new version of config file /etc/fwupd/redfish.conf ... fwupd-offline-update.service is a disabled or a static unit not running, not starting it. fwupd-refresh.service is a disabled or a static unit not running, not starting it. fwupd.service is a disabled or a static unit not running, not starting it. Setting up systemd (245.4-4ubuntu3.24) ... Setting up netplan.io (0.104-0ubuntu2~20.04.6) ... Setting up systemd-timesyncd (245.4-4ubuntu3.24) ... Setting up python3-update-manager (1:20.04.10.23) ... Setting up systemd-sysv (245.4-4ubuntu3.24) ... Setting up cloud-init (24.4.1-0ubuntu0~20.04.3) ... Configuration file &#39;/etc/cloud/cloud.cfg&#39; ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer&#39;s version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** cloud.cfg (Y/I/N/O/D/Z) [default=N] ?
最新发布
12-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值