Qownnotes: Suggestion for Editor enhancement Vi Vim

Created on 11 Jun 2016  路  37Comments  路  Source: pbek/QOwnNotes

VI/VIM Key mode, Integration or embedding of vim/neovim as the editor

Help wanted Feature

Most helpful comment

Yes please. QOwnNotes would be a great tool to use, but without a real editor, it's not something I could work with efficiently.

All 37 comments

Thank you for your suggestion. Any volunteers? :)

Trust me If I knew how I'd be all over it. I know there is an API for hooking into neovim. that may be the easiest way to get it in. then the plugins and full function of vim would be added to qownnotes.

And how should that work? Is there even a GUI version of neovim?

This version that runs in atom works but you have to have the nvim socket open..
https://atom.io/packages/neovim-mode
This works much better but is really just an x11 frontend to neovim
https://github.com/rhysd/NyaoVim

I will close this issue until there is / are more information / volunteers.

I would also like QOwnNotes to have a Vim-Mode. Using vim hotkeys everywhere else makes the use of QOwnNotes a bit annoying at times. It's the one thing I'm missing!

Yes please. QOwnNotes would be a great tool to use, but without a real editor, it's not something I could work with efficiently.

It would very nice to have vim mode in qownnotes editor. :)

Since we have a read-only mode now I maybe will implement some basic vim-shortcuts. :)

Any suggestions? Like:

  • i: insert mode (turns off read-only mode)
  • /: search (opens search bar)
  • Esc: leave edit mode (turns on read-only mode)

Those, but also:

o: open new line below;
O: open new line above;
A: Insert mode at the end of the current line;
a: insert mode after the next character;
v: visual mode; (also ctrl+v)

But also stuff like "ciw" for "change inside word" or "ci(" for "change inside parenthesis", etc..

I first need to get a Text Cursor in read only Mode to make most of those Shortcuts useful

there are a lot of useful key bindings in vim :)

It looks like you are developping in C++ ?

Here some addition useful keybinding :

in Normal mode :

  • h,j,k,l : to move the cursor
  • y, yy : copy the selection, copy the line
  • d, dd : delete the selection, delete the line
  • p : paste
  • x : delete the current position
  • r,R : replace one character, replace mode
  • w, b : go to next word, go to previous word
  • $ : go to the end of line
  • ^ : go to the start of line
  • cw, c$ : change current word, change until the end of line and set insert mode
  • :XX : go to line XX

maybe it exists some library which does already the job because there are a lot of key bindings :)

There might be https://github.com/hluk/FakeVim if I can get it running.

So far I had no luck with the library, it crashes for me (see https://github.com/hluk/FakeVim/issues/40).

I got it to run now. It seems that if we are using FakeVim then most of the shortcuts of OOwnNotes to work inside notes will not work properly... But there vi shortcuts seem to work. Is that a price we want to pay?

I finally got a basic Vim mode working.

18.08.0

  • you can now enable a new Vim mode in the Editor settings

    • keep in mind that some QOwnNotes shortcuts will not work correctly in that mode

There now is a new release, could you please test it and report if it works for you?

WOW! That's the best thing that happened to QOwnNotes in a loooong time! 馃懐 Thanks, and cheers!

It doesn't seem to build on Windows (AppVeyor) yet... :grimacing: More work to do...

V-Block mode doesn't seem to work (Ctrl+v).

EDIT:
Some things I don't like:

  • The block changes sizes (when in visual mode, it would be cool if the block mode kept its size throughout the document, regardless of having selected a letter, an empty space or a dot (".");
  • There is no feedback for the search function: When doing "/search_for_this_string", there should be a bar somewhere (probably at the bottom) indicating that we're searching for "search_for_this_string";
  • It would be cool if when copying using the vim mode, it also copied to the clipboard by default; (this is usually done in the vimrc)

Can you please explain in more detail and step by step what you did, what happened and what you expected.

Sure @pbek:

Let's say you've a document with the following text:

"
aaaabbbbaaaa
aaaabbbbaaaa
aaaabbbbaaaa
"

If you put the cursor on the first "b", then click on "ctrl+v" and go down and right, you should be able to select all the "b"s at once. You can then press "x" to delete them. Well, visual-block mode doesn't seem to work in qownnotes, that is, you can't select columns in visual mode.

Scratch that, V-Block mode seems to work. There's just no visual feedback to it. I can do what I mentioned in the previous post, but the block should be highlighted and it currently is not (I am using the dark theme). (See an example here, in the 2:55 mark)

I didn't even play with dark mode yet...

18.08.2

  • added many improvements to the new Vim mode

    • visible commands in the status bar

    • support for more commands like :w, :q and :wq

    • searching and replacing with more feedback

    • visual mode also works now with more feedback

    • text indenting

There now is a new release, could you please test it and report if it works for you?

Wow !! Thank you @pbek

It works very well on my side with the latest version. Even other command like :%s/search/new/g

I've tested almost all functions mentioned and it all works :) Great work !

Here is some minor feedbacks :

  • cursor is not always the same, it varies depending the character and if there is no character it is "normal"
  • during search i can loose colorization of the pattern, for example if there are multiple match, type 'n' for the next one and colorization disappear but can reappear later (dark mode)

cursor is not always the same, it varies depending the character and if there is no character it is "normal"

I guess that's because the cursor is drawn manually and depends on the size of the character

during search i can loose colorization of the pattern, for example if there are multiple match, type 'n' for the next one and colorization disappear but can reappear later (dark mode)

I'm not sure what can cause this yet...

  • I also don't like that the cursor size is not always the same (when in visual mode);
  • There's a bug with the search. Searching for something and then pressing esc should stop the search. However, does not cancel, in fact, it seems to activate the search (at least the coloring) if one cancels any other way (moving for example);
  • It would be cool if the "-- Command -- " text changed color when we change modes. For example, blue for insert, orange for visual mode, etc.

Thank you for your feedback. Sounds like you want to post some issues / feature requests on https://github.com/hluk/FakeVim/issues. ;)

Sorry @pbek. I thought these were things you could change. It looks great though, thank you for supporting vim-mode.

I thought these were things you could change

technically everyone can, the FakeVim library is FLOSS ;) as well as QOwnNotes is...

It looks great though, thank you for supporting vim-mode.

thank you, I had to spend a lot of time for fixes and integration work :)

about cursor width it can be solved using monospace / fixed-width font in the editor like DejaVu Sans Mono.

@valvin, thank you! It does not completely fix the issue (when there's no character, the cursor is different) but it's much better now!

I've tricked it using the "note editor cursor witdth" but it affects normal and insert mode

screenshot_20180808_201028

Was this page helpful?
0 / 5 - 0 ratings