Codimd: Feature Request: Improve vim support.

Created on 25 Jan 2017  路  18Comments  路  Source: hackmdio/codimd

Hey,
I just stumbled across hackmd in a project meeting. As soon as I saw the optional vim-input support, I became very curious. I understand that there is a lot of functionality you can not pass down in this case, however there is a lot of vim's functionality missing such as:

  • It doesnt help me to record macros with qx if I cannot repeat them with @x.
  • map and imap seem to throw no Error, but do not work either, while nnoremap throws an error

But first of all: Operator-pending mode does not work properly (the last former two points I discovered while making it work, so this is actually most frustrating) ci) or cib in normal mode with cursor the braces of (falafel) should 'change inside braces', thus leave you off with insert-mode and (|) where | is the cursor position. This behaviour should be retained when using dib/di), except that it does not enter inside mode but just deletes the contents of the braces. Of course, it would also be nice if the operators d, c, y... could also be applied to other text objects(i), a), i], a],..., where a stands for around meaning that the surroundings are also considered).

I have no idea how the vim-input support is implemented (do you send it to some hidden vim instance or just define hotkeys and their actions), so I dont know whether it is easy to implement those features.
Is there a chance we get a little more support for motions, text-objects and operator pending mode, some of vim's greatest strengths?

upstream

All 18 comments

Hi @lgalke
Thanks for reporting these.

Unfortunately I'm not a vim pro and our vim mode comes from CodeMirror.
As far as I know, CodeMirror is lacking of vim mode maintainer, so maybe you should take a look there.
https://github.com/codemirror/CodeMirror

Also you could search bunch of issues related to vim mode
https://github.com/codemirror/CodeMirror/search?q=vim&type=Issues&utf8=%E2%9C%93

I am not eager to have it become vim-ish (vim-emulators are annoying because they are not vim), but having features that vim has would be helpful. In particular, column selection of text. Atom has that now as well with their sublime plugin thing. Maybe I will file this as a separate RFE.

@taw00 HackMD has column selection and multiple selection support. On my Computer, alt-Clicking+dragging yields a rectangular selection. Ctrl-Clicking yields a second (and third and ...) cursor.

Thanks for your quick reply, I might have a look at their work then and check whether it's worth to issue some request.
Apart from that, I really appreciate this project. You somewhat feel like in a game, as you see the other 'players' cursors and contest to make the document better. ~~

@jackycute one idea i have in mind would be to open up access via ftp or scp to the files:
That would probably make all the vim users very happy since they could invoke:

vim scp://hackmd.io/<the fancy shared document>

and retain their own vim setup completely. Then it would actually be vim @taw00 .

i think it would be easier writing a socket.io/Etherpad-Protocol connector for vim than a scp/ftp connector for HackMD. The notes are in a database, not on the filesystem (this could be worked around). SCP and FTP don't have any way of pushing updates, so a vim user would be blind to changes by a second author. Effectively, a vim user could only work on files alone, or she would overwrite other people's changes constantly.

Etherpad client in vim has been done: https://github.com/guyzmo/vim-etherpad, AFAIK HackMD uses the same operational transform algorithm, maybe this can be adapted without too much hassle?

@ccoenen Alas, column select on my linux machine does not do this. And I couldn't find a key combination that would. I would love to figure out a mechanism to enable this. Hmm.

What exactly do you mean by column select @taw00 ? For vim Input you can start visual block mode with <C-V> + movement. Pressing s in visual block mode enables you to replace in each line of the block at once, I and A also work for inserting before and after the selection in each line.

@taw00 column-selection-bug should be a separate issue, I believe.

@lgalke Okay. Maybe I don't understand how "vim input" is enabled for hackmd. I know how to column select with vim. But not in the hackmd interface. Maybe I am missing some context here.

In the bottom right corner of the editor view you can select between 'Sublime', 'Emacs', and 'Vim' as input method. @taw00

@lgalke Holy crap. I didn't even see that. Awesome. Column selection works for "vim" but not for "sublime" on linux. That makes my life easier.

Hmm.... now, if text reflow worked like vim, I'd be in heaven. Heh. Different RFE.

@ccoenen HackMD client in vim is a interesting idea.
But I think that should be another issue or repo.

Yes, this was my intention as well. I am not a vim user, so I don't need this one myself. I was merely stating what I think would be the up- and downsides of different ways of implementing this.

I believe this is an entirely different project that could even come from the community.

@ccoenen Totally!
To keep everything in scope and make community works more closely, we will announce 1.0 roadmap soon.
And that can help us to figure out what's open for extension and what's closed for modification.

Since vim support itself is part of Codemirror (the editor inside HackMD) and not directly part of HackMD, I'll close this issue for now. As there is not much we (can) do right now about it and it's inactive.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LukasKalbertodt picture LukasKalbertodt  路  4Comments

ccoenen picture ccoenen  路  3Comments

mxmilkiib picture mxmilkiib  路  3Comments

dsprenkels picture dsprenkels  路  3Comments

Nebukadneza picture Nebukadneza  路  3Comments