1package e2e23import (4 "os"5 "path/filepath"6 "testing"7)89// vimOn turns on File > Settings > Vim keys through the menus.10func vimOn(s *session) {11 s.t.Helper()12 s.keys("<alt+f>", "<up>", "<up>", "<right>", "<down>", "<down>")13 s.waitFor("Move with hjkl")14 s.keys("<enter>")15 s.waitFor("NORMAL")16}1718// Vim keys through a real terminal: letters move and act, counts size19// operators, : goes to cells and writes the file, and :q quits.20func TestVimKeys(t *testing.T) {21 t.Parallel()22 dir := t.TempDir()23 s := start(t, dir)24 vimOn(s)25 s.keys("i", "Rent", "<tab>", "i", "1450", "<enter>")26 s.keys("i", "Food", "<tab>", "a", "600", "<enter>")27 s.keys("=", "SUM(B1:B2)", "<enter>")28 s.waitForLine(gridRow1+2, numRow(3, "2050"))2930 // Shift+letters, $ and counts arrive as typed. Pasted rows go in31 // below, widening the SUM; deleting rows narrows it again.32 s.keys("gg", "$")33 s.waitForBar("B1", "1450")34 s.keys("0", "yy", "2p")35 s.waitForBar("A2", "Rent")36 s.keys("G")37 s.waitForBar("A5", "=SUM(B1:B4)")38 s.waitForLine(gridRow1+4, numRow(5, "4950"))39 s.keys("2k", "2dd")40 s.waitForBar("A3", "=SUM(B1:B2)")41 s.waitForLine(gridRow1+2, numRow(3, "2900"))4243 s.keys("V", "j")44 s.waitFor("VISUAL")45 s.keys("<esc>")46 s.waitFor("NORMAL")4748 s.keys(":", "fill")49 s.waitFor("COMMAND")50 s.waitFor("edit.fill_down")51 s.keys("<esc>", ":B2", "<enter>")52 s.waitForBar("B2", "1450")53 s.keys("x")54 s.waitForBar("B2", "")55 s.keys("u")56 s.waitForBar("B2", "1450")5758 s.keys(":w vim", "<enter>")59 s.eventually("saved", func() bool { return s.title() == "012 - vim.012" })60 if _, err := os.Stat(filepath.Join(dir, "vim.012")); err != nil {61 t.Fatal(err)62 }63 s.keys(":q", "<enter>")64 s.waitExit()65}