heynote
heynote copied to clipboard
Draft: implement vim keymap (Resolves Issue #24)
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 :wink:
Cool! It's nice to see that it seems to mostly work out of the box.
I want Heynote to stay "polished", and having the ∞∞∞
appear when editing is going to feel buggy. Therefore I would want that to be fixed before merging. I'm sure it should be solvable though!
Cool! It's nice to see that it seems to mostly work out of the box.
It was quite a pleasant surprise while I was testing!
I want Heynote to stay "polished", and having the
∞∞∞
appear when editing is going to feel buggy. Therefore I would want that to be fixed before merging. I'm sure it should be solvable though!
completely understandable, I'll try and see what I can do tomorrow (it's quite late right now where I am) and if nothing else, the next guy can use this as a basis to start from!
I started adding vim support myself and then found this branch - nice work!
Some other issues I found with the block delimiters + vim mode:
- When searching with
/
for any part of the delimiter lines (eg, "javascript" from∞∞∞javascript
) it will match the hidden delimiter and not show the cursor (regular ctrl-f search also does this) - From there you could delete the delimiter line (
dd
) to join the blocks above and below, or otherwise modify it - Stuff like
d/j
(delete from cursor to search for letter "j") will operate on the delimiter text - Search/replace (
:%s/cpp/javascript/g
) modifies delimiter text as well - etc
These are all variations of the same theme.
When searching with / for any part of the delimiter lines (eg, "javascript" from ∞∞∞javascript) it will match the hidden delimiter and not show the cursor (regular ctrl-f search also does this)
Yeah, the current search is just using the one that comes with Codemirror. I would like to implement a "block-aware" search. Created issue #60 for that.
Stuff like d/j (delete from cursor to search for letter "j") will operate on the delimiter text Search/replace (:%s/cpp/javascript/g) modifies delimiter text as well
It's likely that we need to copy these implementations into Heynote and make them block aware for the Vim mode.
Hello! I took the liberty to test out this branch as well! Aside from the delimiter issues, it works quite well. Any issues I found was mostly around the delimiter text. I'll try to use this branch as a daily driver for a little while to see if I can find any non-trivial issues!
Is this going to be merged into master for the next release? Lack of vim keybindings is the one thing making it very hard for me to get into the flow of using this. I've stopped for now but will revisit if/when this is added.
Same
Is this going to be merged into master for the next release? Lack of vim keybindings is the one thing making it very hard for me to get into the flow of using this. I've stopped for now but will revisit if/when this is added.
It's not going to merged as long as it has known bugs. Please see my comment, which is just a couple of comments above yours.
I'd love to merge support for Vim key bindings, but then someone needs to do the work. And unfortunately, it's unlikely to be me since I've never used Vim and need to google how to quit anytime Vi opens up in a terminal.
ATTN: Vim nerds
I opted for https://github.com/lukas-reineke/headlines.nvim instead.