Ubuntu Linux使用apt-get安装vim文本编辑器
时间:2020-01-09 10:40:22 来源:igfitidea点击:
在Ubuntu上运行vim file.c命令时,提示未安装vim。
我该如何解决Vim not found错误以及为什么Vim不是Ubuntu Linux上的默认文本编辑器?
如何在Ubuntu Linux中安装完整的vim文本编辑器?
Vim(Vi IMproved)是与Vi向上兼容的文本编辑器。
它可以用于编辑各种纯文本。
它对于编辑用shell,python,perl,c/c ++等编写的配置文件和程序特别有用。
在本教程中,我们将向您展示在Ubuntu Linux上安装install vim文本编辑器。
Ubuntu Linux使用apt安装vim
步骤如下:
- 打开终端应用程序。您也可以按CTRL + ALT + T键盘快捷键
- 通过输入
sudo apt update
命令更新软件包数据库 - 搜索vim软件包运行:
sudo apt search vim
。 - 在Ubuntu Linux上安装vim,执行:
sudo apt install vim
- 通过输入
vim --version
命令来验证vim安装。
让我们详细了解在Ubuntu系统上安装vim的所有步骤。
如何在Ubuntu上安装完整版的Vim
首先打开终端应用程序,然后使用apt命令或apt-get命令更新软件包数据库:
sudo apt update
Hit:1 http://us-central1.gce.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://us-central1.gce.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://us-central1.gce.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease Hit:5 http://archive.canonical.com/ubuntu focal InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.
在Ubuntu Linux上应用所有补丁:
sudo apt upgrade
搜索vim包
运行以下任一命令:
sudo apt search vim sudo apt-cache search vim sudo apt-cache search vim | grep editor
vim - Vi IMproved - enhanced vi editor vim-tiny - Vi IMproved - enhanced vi editor - compact version elvis-tiny - Tiny vi compatible editor for the base system formiko - reStructuredText and MarkDown editor and live previewer kakoune - Vim-inspired, selection-oriented code editor libghc-yi-keymap-vim-dev - Vim keymap for Yi editor libghc-yi-keymap-vim-doc - Vim keymap for Yi editor; documentation libghc-yi-keymap-vim-prof - Vim keymap for Yi editor; profiling libraries python3-editor - programmatically open an editor, capture the result - Python 3.x vim-addon-manager - manager of addons for the Vim editor vim-athena - Vi IMproved - enhanced vi editor - with Athena GUI vim-editorconfig - EditorConfig Plugin for Vim vim-gtk - Vi IMproved - enhanced vi editor (dummy package) vim-gtk3 - Vi IMproved - enhanced vi editor - with GTK3 GUI vim-nox - Vi IMproved - enhanced vi editor - with scripting languages support vis - Modern, legacy free, simple yet efficient vim-like editor
您不必安装上述vim软件包。
通常,我们会在Ubuntu Linux上安装vim或vim-tiny。
获取有关您选择的vim软件包的信息
使用apt如下:
apt show vim-tiny apt show vim
Package: vim Version: 2:8.1.2269-1ubuntu5 Priority: optional Section: editors Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Vim Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 3111 kB Provides: editor Depends: vim-common (= 2:8.1.2269-1ubuntu5), vim-runtime (= 2:8.1.2269-1ubuntu5), libacl1 (>= 2.2.23), libc6 (>= 2.29), libcanberra0 (>= 0.2), libgpm2 (>= 1.20.7), libpython3.8 (>= 3.8.2), libselinux1 (>= 1.32), libtinfo6 (>= 6) Suggests: ctags, vim-doc, vim-scripts Homepage: https://www.vim.org/ Task: server, cloud-image, lubuntu-desktop Download-Size: 1238 kB APT-Sources: http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 Packages Description: Vi IMproved - enhanced vi editor Vim is an almost compatible version of the UNIX editor Vi. . Many new features have been added: multi level undo, syntax highlighting, command line history, on-line help, filename completion, block operations, folding, Unicode support, etc. . This package contains a version of vim compiled with a rather standard set of features. This package does not provide a GUI version of Vim. See the other vim-* packages if you need more (or less).
在Ubuntu上安装vim文本编辑器
打开终端和/或使用ssh客户端登录到远程Ubuntu服务器。
执行以下apt-get命令以安装vim文本编辑器(升级后,执行您自己的密码):
sudo apt-get update sudo apt-get install vim
或者
sudo -s sudo apt-get update apt-get install vim
输出示例:
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libtdb1 libvorbis0a libvorbisfile3 vim-common vim-runtime Suggested packages: libasound2-plugins alsa-utils libcanberra-gtk0 libcanberra-pulse ctags vim-doc vim-scripts The following NEW packages will be installed: libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libtdb1 libvorbis0a libvorbisfile3 vim vim-common vim-runtime 0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded. Need to get 9412 kB of archives. After this operation, 42.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 vim-common all 2:8.1.2269-1ubuntu5 [85.1 kB] Get:2 http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 libasound2-data all 1.2.2-2.1 [19.0 kB] .... .. ... Unpacking libpython3.8:amd64 (3.8.2-1ubuntu1.1) ... Selecting previously unselected package vim-runtime. Preparing to unpack .../10-vim-runtime_2%3a8.1.2269-1ubuntu5_all.deb ... Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime' Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime' Unpacking vim-runtime (2:8.1.2269-1ubuntu5) ... Selecting previously unselected package vim. Preparing to unpack .../11-vim_2%3a8.1.2269-1ubuntu5_amd64.deb ... Unpacking vim (2:8.1.2269-1ubuntu5) ... Setting up libogg0:amd64 (1.3.4-0ubuntu1) ... Setting up libtdb1:amd64 (1.4.2-3build1) ... Setting up libasound2-data (1.2.2-2.1) ... Setting up vim-common (2:8.1.2269-1ubuntu5) ... Setting up libpython3.8:amd64 (3.8.2-1ubuntu1.1) ... Setting up libvorbis0a:amd64 (1.3.6-2ubuntu1) ... Setting up libltdl7:amd64 (2.4.6-14) ... Setting up libasound2:amd64 (1.2.2-2.1) ... Setting up vim-runtime (2:8.1.2269-1ubuntu5) ... Setting up libvorbisfile3:amd64 (1.3.6-2ubuntu1) ... Setting up libcanberra0:amd64 (0.30-7ubuntu1)
验证vim安装
运行以下命令:
vim --version
我如何用vim编辑文件
您现在可以使用vim文本编辑器:
$ vi file.c $ vim file.c $ sudo vim /etc/sysctl.conf