Draft: implement vim keymap (Resolves Issue #24) #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey there, I decided to take a stab at #24 and this is what I came up with.
I used the codemirror-vim package: repo as suggested by @nilsherzig here.
All in all it works without a hitch! cut (dd, dw, d$, etc.), copy (yy, yw, y$, etc.) and paste (p) all work without issue in my testing. Along with this, all the basic movement commands I tested (h, j, k, l, gg, G, w, b), highlighting (Shift-V, Ctrl-v), etc. all worked.
The only issue I managed to find was if you delete the whole line (dd) inside of an empty or 1 line block it uncovers the separator regex for the next block, and the next block inherits the code highlighting of the block you just removed. I tried to find a workaround for this, but with my limited JavaScript skills and lack of understanding of how the app works as a whole, I could only deduce that it had something to do with maybe the extra line break between the separators getting deleted. these comments I think help support this hypothesis.
I am unsure if this issue can be avoided without implementing a custom keymap like what you have in emacs.js. The commented out code in keymap.js was my sad attempt at trying to avoid deleting the extra line break. Perhaps someone with more knowledge with codemirror and it's Vim keybindings package can make a better attempt at fixing the issue!
Overall, I think the net positive of having Vim keybindings is worth the minor headache of having to delete the
∞∞∞text
that pops up and reassign the blocks highlighting, but ultimately that's not my call!PS. Sweet app! I find myself too often pasting things inside of a new tab address bar for temporary jotting. Once I saw your post on Hacker News I knew I had to get it... so long as it had Vim keybindings 😉