Skip to content

๐Ÿ“Ÿ Vim โ€‹

alt
์ถœ์ฒ˜ : VIM! No EXIT !! :D :D

๋งํฌ โ€‹

Use Cases โ€‹

Changing case โ€‹

  • ~ : case ๋ณ€๊ฒฝ ํ›„ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ปค์„œ ์ด๋™
  • {Visual}~: highlighted text case ๋ณ€๊ฒฝ
  • {Visual}U : highlighted text uppercase๋กœ ๋ณ€๊ฒฝ
  • {Visual}u : highlighted text lowercase๋กœ ๋ณ€๊ฒฝ

์ฐธ๊ณ  โ€‹

Indentation โ€‹

  • {Visual}[count]> : ํ˜„์žฌ line count ์ˆ˜ ๋งŒํผ ์˜ค๋ฅธ์ชฝ์œผ๋กœ indent (shiftwidth)
  • >% : curly-braces block ์˜ค๋ฅธ์ชฝ์œผ๋กœ indent
  • >iB : block์„ ์˜ค๋ฅธ์ชฝ์œผ๋กœ indent

์ฐธ๊ณ  โ€‹

Substitution โ€‹

:[range]substitution/from/to/[flags]

  • :%s/from/to/[flags] : ์ „์ฒด ํŒŒ์ผ์„ ํƒ์ƒ‰ํ•˜๋ฉด์„œ substitution์„ ์ˆ˜ํ–‰. %๋Š” ์ „์ฒด ๋ฌธ์ž์—ด์„ ์˜๋ฏธ, s`๋Š” substitution์„ ์˜๋ฏธ
  • :.s/from/to/[flags] : ํ˜„์žฌ๋ผ์ธ์—์„œ substitution์„ ์ˆ˜ํ–‰
  • :.,$s/from/to/[flags] : ํ˜„์žฌ๋ผ์ธ๋ถ€ํ„ฐ ํŒŒ์ผ์˜ ๋๊นŒ์ง€ ํƒ์ƒ‰ํ•˜๋ฉด์„œ substitution์„ ์ˆ˜ํ–‰

์ฐธ๊ณ  โ€‹

Writing and Quiting โ€‹

:x : Like ":wq", but write only when changes have been made.

ZZ : Write current file, if modified, and close the current window (same as ":x").

์ฐธ๊ณ  โ€‹

simple-change โ€‹

v_g_CTRL-X({Visual}g CTRL-X) : Subtract [count] from the number or alphabetic character in the highlighted text. If several lines are highlighted, each value will be decremented by an additional [count] (so effectively creating a [count] decrementing sequence).

์ฐธ๊ณ  โ€‹

์›ํ•˜๋Š” ์—ด๋กœ ์ด๋™ โ€‹

N|: N๋ฒˆ์งธ ์—ด๋กœ ์ด๋™

  • 80A=<ESC>d80|: =๋ฅผ 80๋ฒˆ ๋ฐ˜๋ณต ์ž…๋ ฅํ•œ ํ›„ 80๋ฒˆ์งธ ์—ด๊นŒ์ง€ ์‚ญ์ œ

์ฐธ๊ณ  โ€‹

Open command in editor in zsh (Ctrl + x + e ๋Œ€์ฒด) โ€‹

bash
# .zshrc ๋งˆ์ง€๋ง‰์— ์ถ”๊ฐ€
autoload edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line

v

  • bash vi mode์—์„œ๋Š” v๋ฅผ ์ž…๋ ฅํ•˜๋ฉด editor์—์„œ command๋ฅผ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋„๋ก ์ฐฝ์ด ์—ด๋ฆฐ๋‹ค. ๊ฐ™์€ keybind๋ฅผ ํ•ด์ฃผ๋Š” ๋“ฏ

์ฐธ๊ณ  โ€‹

debt โ€‹