Skip to content

Vi Mode ​

Fresh ships a vi mode for modal editing. Turn it on with Toggle Vi mode from the command palette (Ctrl+P); run it again to go back to Fresh's normal keys. Vi mode applies to the whole editor, in every window, and the status bar shows the current mode.

Its settings are in the Settings UI under Plugins → vi_mode:

  • Auto Start (auto_start) — turn vi mode on whenever Fresh starts (off by default).
  • Arrow Keys (arrow_keys) — let the arrow keys move the cursor in vi's modes (on by default).
  • Search Word Under Cursor (search_word_under_cursor) — * and # search for the word under the cursor (on by default).

Ctrl+P (command palette) and Ctrl+Q (quit) keep working in Normal, Insert and Visual modes, so the rest of Fresh is always one key away.

Modes ​

ModeEnter withWhat it does
NormalEscKeys move the cursor and run commands; typing doesn't insert text
Inserti a I A o OTyping inserts text, as in Fresh's normal editing
VisualvSelect by character
Visual LineVSelect whole lines
Visual BlockCtrl+VSelect a rectangle (a column across lines)
Command line:Type an ex command (see below)

In a visual mode, v, V and Ctrl+V switch between the kinds of selection; pressing the current one again, or Esc, returns to Normal.

Motions ​

KeysMoves to
h j k lleft, down, up, right
w b e / W B Enext word, previous word, end of word (word / WORD)
0 ^ $line start, first non-blank, line end
_ + -first non-blank of this, the next, the previous line
gg / Gfirst / last line (5G goes to line 5)
{ / }previous / next paragraph
%matching bracket
f t F T + charnext / till next / previous / till previous character on the line
; / ,repeat the last f/t/F/T forward / backward
/ / ? then n Nsearch forward / backward, next / previous match
* / #search for the word under the cursor forward / backward
Ctrl+D / Ctrl+Udown / up ten lines
Ctrl+F / Ctrl+Bdown / up a page
zzscroll so the cursor line is centred

Operators ​

An operator followed by a motion or text object acts on that range: dw deletes a word, c$ changes to the end of the line, y% yanks to the matching bracket, dfx deletes through the next x, d; repeats the last find as the range. Doubling an operator acts on the whole line (dd, cc, yy, >>, <<).

KeyOperator
ddelete
cchange (delete, then Insert)
yyank (copy)
> / <indent / dedent

Shortcuts that act without a motion:

KeysAction
x / Xdelete the character under / before the cursor
D / Cdelete / change to end of line
s / Ssubstitute a character / the whole line
Yyank the line
r + charreplace the character under the cursor
p / Ppaste after / before (line-wise yanks paste on their own lines)
Jjoin with the next line
~toggle case
u / Ctrl+Rundo / redo

Yank, delete and change all share one register, which is Fresh's clipboard, so text yanked in vi mode can be pasted anywhere and vice versa.

Text Objects ​

After an operator (diw, ci", ya() or in Visual mode (viw, va{), i selects the inside of an object and a selects it with its surroundings.

KeyObject
w / Wword / WORD
" ' `quoted string
( ) bparentheses
{ } Bbraces
[ ]brackets
< >angle brackets

Counts and Repeat ​

  • A count before a motion or command repeats it: 3w, 5j, 2fx, 3x.
  • Counts work with operators too: 3dd deletes three lines, d3w three words.
  • . repeats the last change, including the text typed in Insert mode. A count before . replaces the original one (3.).

Visual Mode Operators ​

With a selection, d (or x), c (or s), y, > and < act on it and return to Normal. In Visual Block they act on the column, and c types on every line at once. Visual and Visual Line modes also support J to join the selected lines.

Ex Commands ​

Press : to open the command line. Commands can be abbreviated as in Vim (:w, :wq, :bn), and ! forces one that would otherwise refuse because of unsaved changes.

CommandAction
:w / :w filesave / save as another file
:q / :q!quit Fresh (refuses if anything is unsaved) / quit without saving
:wqsave and quit (always writes)
:x, ZZsave if modified, then quit
ZQquit without saving
:wa / :qa / :wqasave all / quit all / save all and quit
:e file / :e!open a file / reload the current one, discarding changes
:42go to line 42
:bn :bp :bd :b name :lsnext / previous / close / switch buffer, list buffers
:sp :vs :close :onlysplit horizontally / vertically, close this split / all others
:new :vnew :enew :tabnewopen a new empty buffer (in a new split for :new / :vnew)
:tabclose :tabnext :tabpreviousclose / next / previous tab
:nohclear search highlighting
:set number / :set nonumbershow / hide line numbers
:set wrap / :set nowrapturn line wrap on / off
:copen / :cnext :cprev :cfirst :clastopen the diagnostics panel / jump between diagnostics

Not Supported ​

Some Vim features have no vi-mode equivalent yet: named registers ("a), marks (m), macro recording with q (use Fresh's own macros), Replace mode (R), and the :s, :g and :! commands (use Fresh's search and replace and terminal instead).

Released under the GNU General Public License v3.0 or later