0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

viエディタでの編集

0
Last updated at Posted at 2021-12-30

viエディタはUNIX系のOSに最初からインストールされているテキストエディタ。
例としてRailsアプリのGemfileをviエディタを用いて編集してみます。

ターミナル
$ vi Gemfile

するとターミナルにGemfileの中身が表示されます。以下のように開いたら成功です。

ターミナル
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.8'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3', '>= 6.1.3.1'

# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
...
(省略)
...
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rails-i18n'
gem 'kaminari'

文字を挿入・削除する場合

iを入力して入力モードに切り替えます。(この時カーソルはどこに位置していても問題ないです)

挿入したい場合は目的の箇所にカーソルを持って行って入力する
削除したい場合は目的の箇所にカーソルを持って行ってBackspaceキーを押す

編集が完了したらescキーを押す

:wqを入力して編集したファイルを保存する

以上。

以上です。viエディタで検索するといっぱいコマンド出てくるしよく慣れないしで最初はすごく慎重にやってましたが、本当に基本的な操作はこれで十分かと思います。
h→カーソルを左
j→カーソルを下
k→カーソルを上
l→カーソルを右
っていつ使うんじゃい!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?