Writeup Aria
RoadMapRoom OtherApplication

Toolbox Vim

room

Task 1

Lets get started! To check whether Vim is installed:

  • Launch a Terminal Window
  • Type "vim"

If you're looking at the Vim splash page

Then you're in luck!

Otherwise type:

  1. Debian-Based Distributions:
sudo apt install vim
  1. Arch-Based Distributions:
sudo pacman -S vim
  1. Fedora-Based Distributions:
sudo dnf install vim-enhanced
  1. Windows: Go to: https://www.vim.org/download.php#pc

Download and install the "self-installing-executable"

Task 2

šŸ”¹ Pengenalan Vim

Vim adalah text editor berbasis terminal yang sangat powerful. Vim bekerja dengan mode, bukan sekadar mengetik seperti editor biasa.

šŸ”¹ Mode di Vim

Ada 3 mode utama yang wajib dipahami:

1ļøāƒ£ Command Mode (Normal Mode)

  • Mode default saat Vim dibuka
  • Digunakan untuk:
    • Navigasi
    • Menghapus teks
    • Menyalin (copy)
    • Menjalankan perintah
  • Tekan Esc kapan pun untuk kembali ke mode ini

2ļøāƒ£ Insert Mode

  • Digunakan untuk mengetik / mengedit teks
  • Masuk ke Insert Mode dengan:
    • i → insert sebelum kursor
    • a → append setelah kursor
    • o → buat baris baru di bawah
    • O → buat baris baru di atas
  • Keluar dengan Esc

3ļøāƒ£ Visual Mode

  • Digunakan untuk menyeleksi teks
  • Masuk dengan:
    • v → seleksi per karakter
    • V → seleksi per baris
    • Ctrl + v → block/column selection
  • Setelah seleksi, bisa langsung:
    • d → delete
    • y → yank (copy)

šŸ”¹ Navigasi Dasar

Vim tidak mengandalkan arrow key, tapi key cluster:

ArahTombol
Kirih
Bawahj
Atask
Kananl

Ingat: h j k l = navigasi utama Vim

  • w → lompat ke awal kata
  • b → lompat ke awal kata
  • e → lompat ke akhir kata
  • gg → ke baris paling atas
  • G → ke baris paling bawah
  • :n → ke baris ke-n (contoh :10)
  • 0 → ke awal baris
  • $ → ke akhir baris

šŸ”¹ Menyisipkan & Menambahkan Teks (Insert vs Append)

Shortcut ini sangat penting agar editing jadi cepat:

PerintahFungsi
iInsert sebelum kursor
aAppend setelah kursor
IInsert di awal baris
AAppend di akhir baris
oBaris baru di bawah
OBaris baru di atas

šŸ’” Tips: Biasakan pakai shortcut ini, jangan cuma i

šŸ”¹ Bantuan di Vim

Vim punya dokumentasi bawaan yang lengkap banget.

Membuka Help

:help

Help untuk Command Tertentu

:help gg

Contoh info dari :help gg:

  • gg = lompat ke awal file
  • Bisa pakai angka → 10gg (lompat ke baris 10)
  • Setara dengan <Ctrl + Home>

šŸ”¹ Kesimpulan

  • Vim berbasis mode
  • Kuasai Normal Mode dulu
  • Hafalkan hjkl
  • Biasakan insert/append shortcut
  • Jangan ragu pakai :help
  • How do we enter "INSERT" mode?

i

  • How do we start entering text into our new Vim document?

typing

  • How do we return to command mode?

esc

  • How do we move the cursor left?

h

  • How do we move the cursor right?

l

  • How do we move the cursor up?

k

  • How do we move the cursor down?

j

  • How do we jump to the start of a word?

w

  • How do we jump to the end of a word?

e

  • How do we insert (before the cursor)

i

  • How do we insert (at the beginning of the line?)

I

  • How do we append (after the cursor)

a

  • How do we append (at the end of the line)

A

  • How do we make a new line under the current line?

o

Task 3

Selamat! šŸŽ‰ Sekarang kamu sudah bisa mengetik, navigasi, dan pakai fungsi dasar Vim. Tinggal satu hal penting: cara keluar dari Vim (biar nggak kejebak šŸ˜„).

Ada 6 cara utama:

  1. :w šŸ‘‰ Simpan file, tidak keluar
  2. :w !sudo tee % (atau edit sebagai root) šŸ‘‰ Simpan file dengan hak root
  3. :wq šŸ‘‰ Simpan dan keluar
  4. :q šŸ‘‰ Keluar jika tidak ada perubahan
  5. :q! šŸ‘‰ Paksa keluar tanpa menyimpan
  6. :wqa šŸ‘‰ Simpan dan keluar semua tab/file aktif
  • How do we write the file, but don't exit?

:w

  • How do we write the file, but don't exit- as root?

:w !sudo tee %

  • How do we write and quit?

:wq

  • How do we quit?

:q

  • How do we force quit?

:q!

  • How do we save and quit, for all active tabs?

:wqa

Task 4

On this page