Skip to content

Instantly share code, notes, and snippets.

@EmperorEarth
Forked from robbiev/go-playground-vim.md
Created July 26, 2021 14:55
Show Gist options
  • Save EmperorEarth/c955d7d95d037fdc995420dffbd79c08 to your computer and use it in GitHub Desktop.
Save EmperorEarth/c955d7d95d037fdc995420dffbd79c08 to your computer and use it in GitHub Desktop.
vim keybindings for the Go Playground at https://play.golang.org

Wasavi is some sort of vim implementation for browser text fields.

Once installed go to https://play.golang.org, you can use INSERT or CTRL+ENTER to enter the vim mode. To quit use the usual vim commands.

Tips:

  • The default keybinding to enter vim mode, CTRL+ENTER, conflicts with the standard playground shortcuts (CTRL+ENTER to format, SHIFT+ENTER to run). I recommend configuring wasavi to not enter vim mode on CTRL+ENTER (just use INSERT or configure something else)
  • Once you remapped CTRL+ENTER, you can have the following workflow:
    1. Enter vim mode (INSERT)
    2. Make changes, :wq
    3. Run or auto-format using the playground's default SHIFT+ENTER or CTRL+ENTER shortcuts
    4. Re-enter vim mode (INSERT)

Recording macros even seems to work. The most annoying thing so far has been that dots are seen as part of words and I'm not used to that, if anyone finds a way to fix that let me know.

Obviously wasavi works on other web pages as well.

For more Go banter see my blog https://garbagecollected.org/ or follow me on Twitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment