Feedback welcome!
OK, let’s see how hard it will be without my .vimrc …
(This is why I’ve never been pro this feature!)
I’ve looked into how much of a vimrc the new Vim mode could use.
The editor’s Vim mode comes from the CodeMirror Vim plugin. It understands a small set of Ex commands, and it can’t run Vim script. If we added a box in the editor settings to paste your vimrc into:
- Mappings would work.
nnoremap,inoremap jk <Esc>,vnoremap < <gvand the other map commands all run. We’d also handlelet mapleader,<leader>and<silent>. - Most
setoptions wouldn’t work yet. The plugin supports only a handful, such astextwidth. - The rest would be skipped. That covers plugins,
autocmd, functions, colour schemes and highlighting. The editor would list the lines it ignored.
Beyond that, we can probably add almost anything people need, apart from running Vim script itself. That includes more set options, commands such as :w to save or run the tests, and the behaviour of popular plugins such as vim-surround or vim-commentary.
Before we build anything, it would help to hear from people who use Vim. Which parts of your vimrc would you miss most in the editor? Would pasting in your mappings cover most of it? Are there specific set options, commands or plugins you’d want?
Can we document those?
That would be my main ask.
- It would be handy to be able to view some settings, like
shiftwidthorexpandtabto see what that language’s config specifies (especially languages that require tabs) - I find
listuseful to spot trailing whitespace.
Here is what the editor’s Vim mode supports today. This list comes from reading the plugin source (@replit/codemirror-vim 6.4.0), so it shows what the plugin defines.
Mappings
:map, :nmap, :imap, :vmap, :omap, :noremap, :nnoremap, :inoremap, :vnoremap, :onoremap and :unmap, plus :mapclear with the same mode prefixes. You can type one at the : prompt, for example :inoremap jk <Esc>. The editor has no vimrc box and no place to store mappings, so I expect a mapping typed this way to last only until the page reloads. I haven’t tested that in the browser.
Options
:set, :setlocal and :setglobal. These options exist: textwidth, filetype, langmap, pcre and insertModeEscKeysTimeout. Any other name gives “Unknown option”.
Editing
:substitute (:s), :global (:g), :vglobal (:v), :normal, :delete, :join, :yank, :put, :sort, :undo, :redo and :startinsert.
Display and marks
:nohlsearch (:noh), :marks, :delmarks, :registers and :colorscheme.
Saving and quitting
:w is defined in the plugin, but the editor doesn’t connect it to saving or running the tests, so I expect it to do nothing. :q isn’t defined.
Mappings from a vimrc are noted as your main ask. Nothing has been scheduled for them, so there is no date to give.
