# 寫扣只用鍵盤,才能空出腦袋 ## Vim ### ex cmd line - `:w`:save - `:q`:quit(+`!`:quit w/o saving) - `:set rnu`:相對行號(+`!`:取消相對行號) - `:reg`:查看 registers ### 模式切換 - 預設 normal mode(其他 mode 皆可用 `Esc` 返回 normal mode) - `a`:insert mode @eoc(`A`:insert mode @eol) - `i`:insert mode @boc(`I`:insert mode @bol) - `v`:visual mode(`V`:以行為單位) - `R`:replace mode ### normal mode #### move(可 num+) - `h` / `j` / `k` / `l`:方向(左 / 下 / 上 / 右) - `w`:next word(`W`:只認空白 / 斷行,不認特殊符號) - `e`:end of next word(`E`:只認空白 / 斷行,不認特殊符號) - `b`:prev word(`B`:只認空白 / 斷行,不認特殊符號) - `^`:bol - `$`:eol - `+`:`j^` - `-`:`k^` #### search - `f`:followed, find char @eoc(`F`:backwards) - `t`:followed, find char @boc(`T`:backwards) - `;`:repeat find char(`,`:reverse) - `/`:entered, find(`?`:backwards) - `*`:find current(`#`:backwards) #### edit - `o`:向下新增一行 & enter insert mode(`O`:backwards) - `J`:join next line / join all lines in visual selection - `r`:replace char - `y`:followed, copy(`Y` / `yy`:current line) - `d`:followed, delete(`D` / `dd`:current line) - `x`:delete char(`X`:left to current char) - `c`:followed, delete & enter insert mode(`C`:`c$`) - `s`:delete current char & enter insert mode(`S`:current line) - `p`:paste after(`P`:before) - registers - 可以註冊 a-z,也可以不設定 - `" <index>`:使用該註冊索引 - copy 或 delete 皆會存入並取代預設 - copy 會被存入 `"0` #### repeat - `;`:repeat find char(`,`:reverse) - `n`:repeat find(`N`:reverse) - `.`:repeat operator / cmd #### pairing marks scope - `%`:goto another pairing mark - `(`:bos(`)`:eos) - `{`:bop(`}`:eop) - `[`:followed by `(` / `[` / `{`, goto opened pairing mark - `]`:followed by `)` / `]` / `}`, goto closed pairing mark - `<operator> i / a <pairing mark>` - `<operator>`:`v` / `d` / `c` / `y` - `i`:不包含 / `a`:包含 - `<pairing mark>` - `{` / `}` / `B` - `(` / `)` / `b` - `[` / `]` - `'` / `"` - `<` / `>` - `t`:tag - `w`:word #### others - `u`:undo - `Ctrl a`:該行右側第一個數字++(可 num+) - `Ctrl x`:該行右側第一個數字--(可 num+) - `gg`:bof - `G`:eof - `H` / `Shift ↑`:PgUp - `L` / `Shift ↓`:PgDn - `M`:PgMd ## Jetbrains ### shortcut - `Opt Enter`:show intention actions & quick-fixes - `F2`:goto error / highlight - `F6`:move - `Ctrl t`:refactor this - `Shift Shift`:search everywhere - `Cmd` - `n`:generate code - `b`:goto declaration - `d`:duplicate current line - `+`:expand code block - `-`:collapse code block - `w`:close tab - `1`:project - `Bs`:delete current line - `Cmd Opt` - `v`:extract variable - `p`:extract parameter - `m`:extract method - `f`:extract field - `n`:inline - `l`:reformat - `←`:previous location - `→`:next location - `Shift F6`:rename - `Cmd F6`:change signature - `Cmd e`:recent files popup - `Cmd Shift e`:recent locations popup - `Opt ↑`:extend selection - `Opt ↓`:shrink selection - `Opt Shift ↑ / ↓`:move current line upward / downward - `Cmd Shift v`:paste from recent buffers - `Shift Enter`:start new line - `Shift ↑ / ↓`:page up / down - `Ctrl r / d`:run / debug - `Ctrl Shift r / d`:select context configuration and run / debug