go-playground icon indicating copy to clipboard operation
go-playground copied to clipboard

Vim keybind `:w[rite]` as a shortcut to run the code

Open ian-h-chamberlain opened this issue 3 years ago • 3 comments

Thanks for this playground, Vim mode was the killer feature I have been looking for that sets this playground well above any other I have used!

On macOS, I can easily enough use ⌘+⏎ as a shortcut to run the code on the playground, which is nice. I have muscle memory for :w (:write) in Vim's normal mode to save a file, so it would be nice if this was also a shortcut for the same action.

As it stands, it seems the :w command is recognized somehow. I don't see an error like the following: Screen Shot 2022-08-09 at 13 20 50 However, it doesn't appear to actually do anything (format / submit). Would you consider a change to map :w as a shortcut meaning the same as cmd+enter?

ian-h-chamberlain avatar Aug 09 '22 17:08 ian-h-chamberlain

Hello @ian-h-chamberlain and thank you for the feedback.

The ⌘+⏎ shortcut and VIM commands are implemented in different way.

A quick run shortcut is actually a monaco editor action.

The vim mode is actually a hacky adapter that listens for commands on top of monaco.

This implementation is actually a port of other vim-emulation library and command handler is implemented inside that library.

But I'll try to look into that.

x1unix avatar Aug 09 '22 21:08 x1unix

Thanks for the quick response! From their README, it looks like you might just be able to bind an ex mode command to wire up the submit action, as long as the :<cmd><Enter> keypresses still end up propagating to the VimMode handler? Thanks for looking into it!

ian-h-chamberlain avatar Aug 10 '22 14:08 ian-h-chamberlain

@ian-h-chamberlain thank you for the research :)

x1unix avatar Aug 10 '22 21:08 x1unix

Will be shipped in a next release.

x1unix avatar Oct 22 '22 06:10 x1unix