rhysd / vim.wasm Goto Github PK
View Code? Open in Web Editor NEWVim editor ported to WebAssembly
Home Page: http://rhysd.github.io/vim.wasm
Vim editor ported to WebAssembly
Home Page: http://rhysd.github.io/vim.wasm
A vim plugin like killersheep does not fully work.
Support sound feature (enable sound
feature in :version
) using Web Audio API.
None
An exception is sometimes thrown as #28 (comment) reported.
Not sure, but sending key input sometimes causes this.
Not crash
Crash with exception thrown
Shown above
VimWasm.cmdline()
runs given command, but screen is not updated. To avoid this, appending | redraw
to the command is necessary.
vim.cmdline('edit ~/.vim/vimrc')
Screen renders the content of ~/.vim/vimrc
Screen is not updated though only statusline is updated to notify opening ~/.vim/vimrc
:set number<CR>
OS: macOS 10.12
Browser: Chrome 67.0.3
Working in Firefox (And maybe other browsers).
try:
:colo ((press C-D))
it does not output the possible completions.
The options are shown using , as expected, though.
On https://rhysd.github.io/vim.wasm/ page,
I type the following sequence
ihohoho<esc>
:%s/o/i/gc<enter>
I then cannot do anything else, page seem to be "frozen".
Describe the bug
In vim previous commands entered (possibly only the ones that executed successfully, I'm not too sure I'm afraid) can be replayed by pressing up in command mode.
Steps To Reproduce
type
:%s/foo/bar/
then press enter
then type (colon, then press up arrow)
:<Up>
Expected behavior
:%s/foo/bar/
is in the command bar, ready to be executed by pressing enter
Actual behavior
prints a literal
:<Up>
to the command bar, rather than displaying previous command -> :%s/foo/bar/
Screenshots/DevTools console (if possible)
see bottom, sorry there's a lot on the console
Your environment:
Additional context (if any)
The Components object is deprecated. It will soon be removed. vim.wasm
Error detected while processing /usr/local/share/vim/colors/desert.vim:
index.js:1:40840
put_char
https://rhysd.github.io/vim.wasm/index.js:1:40840
write
https://rhysd.github.io/vim.wasm/index.js:1:39443
write
https://rhysd.github.io/vim.wasm/index.js:1:83857
doWritev
https://rhysd.github.io/vim.wasm/index.js:1:104304
___syscall146
https://rhysd.github.io/vim.wasm/index.js:1:130894
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:369608:2147484861
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:341315:2147484806
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:435028:2147485154
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:6738:2147483759
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:519447:2147485385
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:34464:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:6322:2147483748
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:38261:2147483791
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:229175:2147484476
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:59596:2147483929
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:136844:2147484169
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:5720:2147483736
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:15509:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:74271:2147483986
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:48355:2147483856
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:591698:2147485518
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:199388:2147484373
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:327296:2147484791
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:91933:2147484029
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:470186:2147485272
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:606034:2147485606
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:15298:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:74271:2147483986
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:48355:2147483856
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:533302:2147485417
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:32642:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:615257:2147485673
Module._main
https://rhysd.github.io/vim.wasm/index.js:1:170474
callMain
https://rhysd.github.io/vim.wasm/index.js:1:172730
doRun
https://rhysd.github.io/vim.wasm/index.js:1:173529
run
https://rhysd.github.io/vim.wasm/index.js:1:173715
runCaller
https://rhysd.github.io/vim.wasm/index.js:1:172316
removeRunDependency
https://rhysd.github.io/vim.wasm/index.js:1:23053
receiveInstance
https://rhysd.github.io/vim.wasm/index.js:1:25621
receiveInstantiatedSource
https://rhysd.github.io/vim.wasm/index.js:1:25929
line 22:
index.js:1:40840
put_char
https://rhysd.github.io/vim.wasm/index.js:1:40840
write
https://rhysd.github.io/vim.wasm/index.js:1:39443
write
https://rhysd.github.io/vim.wasm/index.js:1:83857
doWritev
https://rhysd.github.io/vim.wasm/index.js:1:104304
___syscall146
https://rhysd.github.io/vim.wasm/index.js:1:130894
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:369608:2147484861
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:341315:2147484806
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:435028:2147485154
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:6738:2147483759
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:519447:2147485385
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:34464:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:6322:2147483748
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:38261:2147483791
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:229175:2147484476
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:59596:2147483929
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:5736:2147483736
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:15509:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:74271:2147483986
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:48355:2147483856
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:591698:2147485518
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:199388:2147484373
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:327296:2147484791
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:91933:2147484029
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:470186:2147485272
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:606034:2147485606
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:15298:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:10477:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:74271:2147483986
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:48355:2147483856
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:533302:2147485417
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:32642:2147483767
<anonymous>
https://rhysd.github.io/vim.wasm/index.wasm:615257:2147485673
Module._main
https://rhysd.github.io/vim.wasm/index.js:1:170474
callMain
https://rhysd.github.io/vim.wasm/index.js:1:172730
doRun
https://rhysd.github.io/vim.wasm/index.js:1:173529
run
https://rhysd.github.io/vim.wasm/index.js:1:173715
runCaller
https://rhysd.github.io/vim.wasm/index.js:1:172316
removeRunDependency
https://rhysd.github.io/vim.wasm/index.js:1:23053
receiveInstance
https://rhysd.github.io/vim.wasm/index.js:1:25621
receiveInstantiatedSource
https://rhysd.github.io/vim.wasm/index.js:1:25929
index.js:1:40543
TODO: set_shellsize 1288 910 65 184 index.js:1:40543
If you enter a command like :w filename
, and hit enter, then press :
to get back to command mode and press the up arrow key, it should go back in the command history and pull up :w filename
, but instead it inserts :<Up>
. This happens with all four arrow keys.
Describe the bug crash
Steps To Reproduce write text, shift-v down arrow / up arrow, y/d, p, repeat
Expected behavior works fine
Actual behavior crashes at some point
Screenshots/DevTools console (if possible)
Your environment:
Additional context (if any) I'm not sure exactly of the steps to reproduce
When passing an empty string as command line argument of Vim, Vim crashes on start.
import { VimWasm } from '/path/to/vim-wasm/vimwasm.js';
const vim = new VimWasm({ ... });
vim.start({ debug: true, cmdArgs: [ '' ] });
Run above script in browser and check console in DevTools.
Or access to http://rhysd.github.io/vim.wasm/?arg=
Vim normally starts with an unnamed buffer
Vim crashes with following abort error:
worker: Error was thrown in worker: abort("TypeError: Cannot read property 'mode' of null") at Error
at jsStackTrace (http://localhost:1234/vim.js:1374:13)
at stackTrace (http://localhost:1234/vim.js:1391:12)
at abort (http://localhost:1234/vim.js:8200:44)
at ___syscall33 (http://localhost:1234/vim.js:5581:69)
at _access (wasm-function[4982]:59)
at _readfile (wasm-function[1636]:2316)
at _open_buffer (wasm-function[175]:1086)
at _create_windows (wasm-function[4640]:792)
at _vim_main2 (wasm-function[4638]:1543)
at _wasm_main (wasm-function[4629]:1356)
Describe the bug
Text artifacts are visible on any large changes to text.
Steps To Reproduce
Open vim.wasm, enter insert mode to remove the starter text.
Expected behavior
All previous text should be gone and no white marks of a previous text should be visible.
Actual behavior
There are white marks of the previous text
Screenshots/DevTools console (if possible)
https://i.imgur.com/IwlLIJv.gif
Your environment:
Additional context (if any)
Tested with both browsers at different window sizes.
Tested on 1920x1080 and 3840x2160 resolution
Testing device has embedded graphics and a dedicated GPU
As described in known issues, disabling Emterpreter would make execution more stable and faster. For that, an event loop for waiting user input must be async to use JavaScript's setTimeout()
.
I looked in the readme, but didn't see anything. Is there any relationship between this project and https://github.com/coolwanglu/vim.js ?
Great work! 👏
The installation process of vim.wasm is not documented.
Provide installation instruction or provide a Dockerfile for quick deployement.
Thank you, very neat project.
In most cases, the vimWasm.cmdline()
method does not work as expected. I anticipate that cmdline()
should function similarly to manually using Vim's execution mode.
Here are examples of bugs:
vimWasm.cmdline('startinsert')
should change Vim to insert mode, but it does not work.
vimWasm.cmdline('2')
is supposed to move the cursor to line 2, but I don't see the cursor updating. Even after trying to redraw vimWasm.cmdline('2 | redraw')
, it still doesn't work.
@rhysd Please help to find solutions. Thanks
There is a project called PDCurses.js
which actually allows linking with lcurses
. Just wondering if you have considered using it instead of writing the terminal interaction manually. The advantage would be to compile the original project without the need to hack the original files and its compiled size is small too.
Describe the bug
I Can not input chinese characters with vim.wasm
Steps To Reproduce
Expected behavior
It shows "你好,世界" in the vim.wasm.
Actual behavior
It shows "nihao,shijie" in the vim.wasm.
Screenshots/DevTools console (if possible)
Your environment:
Additional context (if any)
None
Describe the bug
Typing ":w foo" (and Enter) makes the tab unusable
Steps To Reproduce
:w foo and Enter
Expected behavior
Actual behavior
Tab gets stuck and nothing responds.
Screenshots/DevTools console (if possible)
Your environment:
Additional context (if any)
i
to enter insert modeOne of the problems with vim.wasm is that there is no facility to choose where to save the typed code. This is a problem when you write code and want the copy to be kept somewhere else for backup or for data security reasons.
I would like to have an option in vim.wasm to choose the storage location. For example, I could save all the code I'm typing in vim.wasm directly to google drive, dropbox, trezorit or I could save it through a protocol like IPFS, FTP etc.
This is not an issue, nor appropriated for the Vim mailing list. However, since this is basically a version of Vim for the web it would make sense to offer some of the features you would expect from a web editor, such as saving. The :w
command could for example trigger a file download. Likewise, opening a file could ask the user to select a file to upload.
Lines 5 to 8 in 97335e7
Trying to generate the vim.wasm
file from a release tarball, I get an error because there's no .git
folder. I understand this behaviour is to prevent errors, but in that case, I think is superfluous and should be removed.
When trying to use the regular command to switch splits, the browser intercepts the command and tries to close the browser window
In the help text, introduce the ':winc " for moving between splits.
Open vim.wasm
split a window ( :sp )
Try to use ctrl-w to move windows
A downstream project as well as the demo on https://rhysd.github.io/vim.wasm/ are now broken on most browsers, since SharedArrayBuffer has been disabled
Run https://rhysd.github.io/vim.wasm/
vim opens up
Alert popup with message FATAL: SharedArrayBuffer is not supported by this browser. If you're using Firefox or Safari, please enable feature flag.
https://caniuse.com/?search=SharedArrayBuffer
https://hacks.mozilla.org/2020/07/safely-reviving-shared-memory/
When I visual select some code, I notice that it's triggering the onWriteClipboard
No clipboard when visual selecting
Clipboard when visual selecting
On setting filetype dist#...
function does not exist and causes an error
foo.html
html
filetype is set
Error as follows
Error detected while processing BufNewFile Autocommands for "*.html":
E117: Unknown function: dist#ft#FThtml
Hello,
Is there any instruction how to rebase from vim/vim to fetch the latest changes?
Backspace(以下BS)で文字を消すことができなかったのでご報告致します
OS : Windows 10
Browser : Firefox (プライベートブラウズも試しました)
再現方法 :
a → 適当な文字列を打つ → BS(この時カーソルは一文字戻りますが、文字が消えません。また、戻ったカーソルにさらに文字を打つと上書きするような動きをします)
そのあと、 Esc → a → 適当な文字列を打つ → BS(この時はBS自体が利かなくなります)
:version<CR>
Thanks to @tyru for the report
I want to have a single "vim.html" where everything is contained, even if it makes the file bigger. I already embedded the "VimWasm.js" inside a <script>.
So in this I only have to "import" the "vim.js" file like this:
const screenCanvasElement = document.getElementById('vim-screen');
const vim = new VimWasm({ // VimWasm is available in the global scope via window.VimWasm(loaded via <script>)
workerScriptPath: './node_modules/vim-wasm/small/vim.js',
canvas: screenCanvasElement,
input: document.getElementById('vim-input'),
});
The problem is that when you're inside of vim.js it uses fetch
to get the vim.wasm binary so you need a server running to have this working.
The solutions would be that you can actually embed .wasm inside of a .html file via base64 encoding, this might not be the most good for performance but for portability it's great!( see https://stackoverflow.com/questions/52582367/a-single-file-webassembly-html-demo and https://gist.github.com/dio/ae79cf546e808a9bc46515bf9400ad5d)
I have tried edit the code myself but it uses both WebAssembly.instantiate
and WebAssembly.instantiateStreaming
so I'm not exactly sure what to do thus I'm opening this issue.
The page stays black when accessing https://rhysd.github.io/vim.wasm/ with firefox.
" '' should be object " appears on the bottom of the page as shown in the attached image.
The screen like vim will appear.
The page stays black.
Ideally this would result in an alert saying "Type :qa! and press to abandon all changes and exit vim". Anything else is simply not true to the vim experience (ignoring for the moment that :q
doesn't actually work, which it probably should)
We have a Qt-based desktop application for medical image processing and we use python code as a kind of macro language to extend and automate the program.
We'd like to be able to use a full featured editor integrated within the application to work with our python code.
Because our app uses Qt, we have the QWebEngine available and can embed a full featured web browser in our app, and we can call browser's javascript environment from python (e.g. like in this test code). Note that it's all asynchronous on both the javascript and python sides.
Recently the question came up about using a full editor to edit the python code in our app, and I found that I can run you vim.wasm code in our embedded browser:
https://discourse.slicer.org/t/directly-interacting-with-python-console/34455/7
But I don't see any easy way to get/set the contents of the editor window or be notified in javascript of vim events.
I'd like to be able to start the vim.wasm context in the browser and then call a javascript function to populate the current text buffer for editing. Then I'd like to be able to use vim keystrokes to trigger javascript code in the browser that would make calls back to the python code, for example to send selection buffers to python for execution.
I tried using the ?debug
argument to set the vim
object as window.vim
and while I could access vim
in the debug console I didn't see any way to set or get the values of the current vim buffers. It would be great if window.vim
were available to interact with the browser's javascript enviornment.
Thanks in advance - I'm a long-time vi/vim user and having this available would make me very happy : )
To replicate:
Nothing happens.
Allow the live demo to be installed as a PWA (Progressive Web App).
Allowing the live demo to be installed could include great features such as:
Implement a service worker to cache vim.wasm and the files to run it in the browser.
Add a web manifest to help the browser install it.
Some good tutorials can be found at web.dev (https://web.dev/tags/progressive-web-apps/)
Is there a reason why there is only a single colorscheme; https://github.com/rhysd/vim.wasm/tree/wasm/wasm/usr/local/share/vim/colors
Is it possible to have more colorschemes; https://github.com/vim/vim/tree/master/runtime/colors
After cloning the repo and building it using ./build.sh, running a local server and hosting vim.html raises quite a few errors.
Following the steps under Development of the README file, raised these errors.
Vim should run without any problems in the browser
But what I see is a blank screen with multiple errors in the console
Your environment:
Is your feature request related to a problem? Please describe.
I couldn't paste some code I wanted to reformat. Felt like vim.wasm could possibly do this, (mostly for convenience) on a Chromebook. 😄
In particular, I wanted a simple reformat, which I knew I could do quickly in Vim:
In:
#Array
#Complex
#Float
#Hash
#Integer
#Rational
#String
Out:
(`Array()`, `Complex()`, `Float()`, `Hash()`, `Integer()`, `Rational()`, `String()`)
Describe the solution you'd like
Add support for pasting via Ctrl-V/Cmd-V, "+p
, or another solution. Add a short blurb somewhere on the page describing this.
Additional context (if any)
n/a
Could you create a page that pre-populates this with the text of vimtutor?
http://www2.geog.ucl.ac.uk/~plewis/teaching/unix/vimtutor
This would be a really cool tool for trying out vim!
Error when running build.sh
Run build.sh
No error . .
Error
BTW, this project is a great idea! - I have been wondering for years how getting Vim going in the browser might be done!
Phil.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.