Cách cài đặt vim trên OpenSUSE/SUSE Linux bằng zypper

Bạn cần trình soạn thảo văn bản VIM trên cloud server OpenSUSE nhưng nó lại không có sẵn. Làm cách nào để cài đặt vim trên OpenSUSE/SUSE Linux?

Bài viết này sẽ chỉ cho bạn cách cài đặt trình soạn thảo văn bản VIM trên OpenSUSE/SUSE Linux (SELS) sử dụng lệnh zypper.

Cách cài đặt vim trên OpenSUSE/SUSE Linux

VIM có nghĩa là Vi IMproved và thường được gọi là trình soạn thảo văn bản của lập trình viên. VIM rất phổ biến trong sysadmins, kỹ sư DevOps, những người dùng Linux thông thường. Theo mặc định, OpenSUSE Linux không đi kèm với vi hoặc vim. Tuy nhiên, chúng ta có thể tìm kiếm và cài đặt VIM như sau.

Bước 1: Tìm kiếm các gói vim

Mở terminal và nhập lệnh sau. Chúng ta có thể tìm kiếm gói vim bằng siêu dữ liệu cho các từ khóa. Sử dụng lệnh sau:

$ sudo zypper search vim

Kết quả sẽ nhận được như sau:

Loading repository data...
Reading installed packages...
 
S | Name                      | Summary                                                             | Type
--+---------------------------+---------------------------------------------------------------------+-----------
  | gvim                      | A GUI for Vi                                                        | package
  | llvm-vim-plugins          | Vim plugins for LLVM                                                | package
  | llvm5-vim-plugins         | Vim plugins for LLVM                                                | package
  | llvm7-vim-plugins         | Vim plugins for LLVM                                                | package
  | meson-vim                 | Vim support for meson.build files                                   | package
  | neovim                    | Vim-fork focused on extensibility and agility                       | package
  | neovim                    | Vim-fork focused on extensibility and agility                       | srcpackage
  | neovim-lang               | Translations for package neovim                                     | package
  | python-Jinja2-vim         | Jinja2 syntax files for Vim                                         | package
  | python2-neovim            | Python client to Neovim                                             | package
  | python3-neovim            | Python client to Neovim                                             | package
  | rtorrent-vim              | Vim syntax file for rTorrent's config file                          | package
  | texlive-context-vim       | Generate ConTeXt syntax highlighting code from vim                  | package
  | texlive-context-vim-doc   | Documentation for texlive-context-vim                               | package
  | vagrant-vim               | Vagrantfile syntax files for the vim editor                         | package
  | vim                       | Vi IMproved                                                         | package
  | vim                       | Vi IMproved                                                         | srcpackage
  | vim-bootstrap             | Vim Bootstrap is a vimrc generator                                  | package
  | vim-data                  | Data files needed for extended vim functionality                    | package
  | vim-data-common           | Common Data files for vim & gvim                                    | package
  | vim-icinga2               | Vim syntax highlighting for icinga2                                 | package
  | vim-plugin-NERDcommenter  | A plugin that allows for easy commenting of code for many filetypes | package
  | vim-plugin-NERDtree       | A tree explorer plugin for navigating the filesystem                | package
  | vim-plugin-a              | Alternate files quickly                                             | package
  | vim-plugin-ack            | Run the ack search tool from Vim                                    | package
  | vim-plugin-align          | Plugin to produce aligned text, equations, declarations, etc        | package
  | vim-plugin-bufexplorer    | Buffer Explorer / Browser                                           | package
  | vim-plugin-calendar       | Calendar for vim                                                    | package
  | vim-plugin-colorschemes   | Vim color schemes selection                                         | package
  | vim-plugin-colorsel       | A RGB/HSV color selector                                            | package
  | vim-plugin-conky          | Conky Configuration File Support for Vim                            | package
  | vim-plugin-devhelp        | Devhelp plugin for Vim                                              | package
  | vim-plugin-diffchanges    | Show changes since the last save                                    | package
  | vim-plugin-editorconfig   | EditorConfig plugin for Vim                                         | package
  | vim-plugin-fugitive       | Fugitive plugin for Vim                                             | package
  | vim-plugin-gitdiff        | Show git diff in a split window                                     | package
  | vim-plugin-gnupg          | Plugin for transparent editing of gpg encrypted files               | package
  | vim-plugin-latex          | A rich set of tools for editing LaTeX                               | package
  | vim-plugin-locateopen     | Edit file without entering the whole path                           | package
  | vim-plugin-matrix         | Matrix screensaver for vim                                          | package
  | vim-plugin-minibufexpl    | Elegant buffer explorer that takes very little screen space         | package
  | vim-plugin-multiplesearch | Display multiple searches at the same time                          | package
  | vim-plugin-neomutt        | Neomutt plugin for Vim                                              | package
  | vim-plugin-nginx          | VIM support for nginx config files                                  | package
  | vim-plugin-powerline      | Powerline VIM plugin                                                | package
  | vim-plugin-project        | Organize/Navigate projects of files                                 | package
  | vim-plugin-quilt          | Quilt support for vim                                               | package
  | vim-plugin-rails          | Support for Ruby on Rails development                               | package
  | vim-plugin-searchcomplete | Tab completion of words inside of a search                          | package
  | vim-plugin-showmarks      | Visually shows the location of marks                                | package
  | vim-plugin-snipmate       | Implements some of TextMate's snippets features in Vim              | package
  | vim-plugin-supertab       | Easy insert mode completion with Tab key                            | package
  | vim-plugin-taglist        | Source code browser with support for many languages                 | package
  | vim-plugin-tlib           | Utility functions for vim                                           | package
  | vim-plugin-tregisters     | List, edit, and run/execute registers/clipboards                    | package
  | vim-plugin-tselectbuffer  | A quick buffer selector/switcher                                    | package
  | vim-plugin-tselectfiles   | A quick file selector/browser/explorer                              | package
  | vim-plugin-utl            | Universal text linking for vim                                      | package
  | vim-plugin-vimwiki        | Personal wiki for vim                                               | package
  | vim-plugin-zoomwin        | Zoom in/out of windows (toggle between one window and multi-window) | package

Bước 2: Nhận thông tin về gói vim trên OpenSUSE hoặc SUSE Enterprise Linux

Vì vậy, những gì chúng ta cần là gói vim. Để tìm hiểu thông tin phiên bản ứng dụng, chạy:

$ sudo zypper info vim
$ sudo zypper info vim-plugin-nginx

Output mẫu:

Loading repository data...
Reading installed packages...
 
 
Information for package vim:
----------------------------
Repository     : Main Update Repository
Name           : vim
Version        : 8.0.1568-lp151.5.6.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 3.1 MiB
Installed      : No
Status         : not installed
Source package : vim-8.0.1568-lp151.5.6.1.src
Summary        : Vi IMproved
Description    : 
    Vim (Vi IMproved) is an almost compatible version of the UNIX editor
    vi. Almost every possible command can be performed using only ASCII
    characters. Only the 'Q' command is missing (you do not need it). Many
    new features have been added: multilevel undo, command line history,
    file name completion, block operations, and editing of binary data.

Bước 3: Cài đặt VIM trên máy chủ OpenSUSE Linux 15.1

Thực hiện lệnh zypper sau để cài đặt vim:

$ sudo zypper install vim

Bước 4: Bắt đầu sử dụng vim

Tất cả bạn phải làm là gõ lệnh sau:

$ vim filename
$ sudo vim /etc/nginx/nginx.conf
$ vim [options] do-to-rds-migration.sh

Chúng ta có thể tạo một bí danh Bash vĩnh viễn:

$ alias vi='vim'

Tiếp theo, thêm bí danh bash shell vào tệp ~/.bashrc hoặc ~/.bash_aliases:

$ echo "alias vi='vim'" >> ~/.bashrc

Tải lại, nhập:

$ source ~/.bashrc

Chúng ta cũng có thể đặt vim làm trình soạn thảo văn bản mặc định trên toàn hệ thống SUSE Linux Enterprise Server (SLES) như sau:

$ sudo -i
# echo 'export VISUAL="vim"' > /etc/profile.d/vimeditor.sh
# echo 'export EDITOR="vim"' >> /etc/profile.d/vimeditor.sh

Hướng dẫn sử dụng VIM

Bạn chưa quen với VIM? Bạn có muốn tìm hiểu tất cả về các lệnh và trình soạn thảo Vim không? Không cần phải tìm kiếm trên Internet hoặc mua sách về học. VIM có đi kèm hướng dẫn đầy đủ từ đầu đến cuối. Tất cả bạn phải làm là gõ lệnh sau tại shell prompt:

$ vimtutor

Đối số [ngôn ngữ] tùy chọn là tên gồm hai chữ cái của một ngôn ngữ, như “it” hoặc “es”. Để liệt kê các ngôn ngữ đã cài đặt, hãy chạy lệnh ls sau:

$ ls -l /usr/share/vim/vim*/tutor/

Sau đó gõ:

$ vimtutor es
$ vimtutor lv
$ vimtutor tr
$ vimtutor it

Cài đặt VIM Plugin

Trước tiên chúng ta phải tìm kiếm các gói và plugin liên quan đến vim như sau:

$ sudo zypper search vim

Giả sử bạn muốn cài đặt hỗ trợ cho Ruby on Rails, hãy dùng lệnh:

$ sudo zypper install vim-plugin-rails

Kết luận

Vi là trình soạn thảo dựa trên màn hình thực sự đầu tiên cho UNIX, và vẫn rất phổ biến trong các hệ thống và lập trình viên. VIM cải thiện vi bằng cách thêm các tính năng mới, nhiều cửa sổ hơn, hoàn tác nhiều mức độ, highlight khối,...

Thứ Ba, 07/07/2020 08:20
31 👨 309
0 Bình luận
Sắp xếp theo
    ❖ Linux