Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Featuer request: commands for simple text-editing #114

Closed
parisni opened this issue Feb 1, 2020 · 14 comments
Closed

Featuer request: commands for simple text-editing #114

parisni opened this issue Feb 1, 2020 · 14 comments

Comments

@parisni
Copy link

parisni commented Feb 1, 2020

hi

first of all, this plugin is promizing.

one thing I guess is missing is to allow shortkey in editing mode.
for example when writing in a textarea, I d´like to add shortkey for

  • delete previous word
  • go to previous/next word
  • go to previous/next line

this beavior exist in the vomnibar, that would be fantastic in any textarea/input fields

thanks

@gdh1995
Copy link
Owner

gdh1995 commented Feb 1, 2020

Sorry but Vimium C is not designed to be an "online text editor". In the meanwhile, there have been some web extensions supporting such VIM-like editing usages, and you may use https://chrome.google.com/webstore/detail/wasavi/dgogifpkoilgiofhhhodbodcfgomelhe .

Similar topics have been discussed for some days in philc/vimium#3405 .

@gdh1995
Copy link
Owner

gdh1995 commented Feb 1, 2020

It's easy to only add 3~4 new commands for word-level operations to Vimium C, but I'm not sure whether it's worth - a full-featured editor is very hard to implement, and large, of course.

BTW, on Chrome Ctrl+Left, Ctrl+Right, Ctrl+Backspace can do such actions.

@parisni
Copy link
Author

parisni commented Feb 1, 2020

thanks for the pointer. I am looking for much basic solution.
the cvim extension provides such shortkeys and I mapped them to
<M-b> : previous word
<M-Delete> : delete previous word

and so on.

Do you think that might be easy to implement in your library ?

@gdh1995
Copy link
Owner

gdh1995 commented Feb 1, 2020

Well, it's indeed easy now, and I can add it tomorrow, so the new command will be in v1.81.2. I'll upload a .zip file for you to test.

The Chrome Web Store takes 3~5 days to verify every new version of Vimium C, and for now they're verifying v1.81.1 ...

@gdh1995 gdh1995 changed the title featuer request Featuer request: commands for simple text-editing Feb 1, 2020
@parisni
Copy link
Author

parisni commented Feb 1, 2020

wow. incredible. thanks

gdh1995 added a commit that referenced this issue Feb 1, 2020
This is for #114

Usage:
```
mapkey <a-b> <f3edit>
map <f3edit> editText sel args=["move","backward","word"]
mapkey <a-f> <f3editf>
map <f3editf> editText sel args=["move","forward","word"]
```
@gdh1995

This comment was marked as outdated.

@parisni
Copy link
Author

parisni commented Feb 1, 2020

working great so far for moving !

I guess cool features are also (the basic readline shortkey as known in bash):

  • delete word foward/backward ( / <a-delete<)
  • go up/down ( / )

many thanks, hope this will be helpful to others

@gdh1995
Copy link
Owner

gdh1995 commented Feb 2, 2020

A new version supporting sequential actions: vimium_c-1.80.1-chrome-93c7356.zip

# delete a forward word
mapkey <a-f:i> <f3editf>
map <f3editf> editText run="extend,forward,word,exec,delete,"

The run option means a list of directive, which will be splitted into a list of 3-directive groups, and in each 3-directive group the first can only be extend, modify or exec, and extend & modify are for Selection::modify, exec are for Document::execCommand, and the later 2 directives are function arguments.

You can assemble any numbers of directives as you like, and please read https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand for the list of available document commands and https://developer.mozilla.org/en-US/docs/Web/API/Selection/modify for available selection operations.

@parisni
Copy link
Author

parisni commented Feb 2, 2020

fantastic!
However the vomnibar does not provide the shortkey anymore. Looks like they have been overwride ?

Here is my config:

mapkey <a-b> <f3edit>
map <f3edit> editText run="move,backward,word,exec,move,"

mapkey <a-f> <f3editf>
map <f3editf> editText run="move,forward,word,exec,move,"

# delete a forward word
mapkey <a-d> <f3rmf>
map <f3rmf> editText run="extend,forward,word,exec,delete,"

# delete forward character
mapkey <c-d> <f3rmcf>
map <f3rmcf> editText run="extend,forward,character,exec,delete,"

# delete backward word
mapkey <a-backspace> <f3rm>
map <f3rm> editText run="extend,backward,word,exec,delete,"

# delete backward character
mapkey <c-h> <f3rmc>
map <f3rmc> editText run="extend,backward,character,exec,delete,"

mapkey <c-e> <f3end>
map <f3end> editText run="move,forward,lineboundary,exec,move,"

# not used because mapped to select text. use home instead
# mapkey <c-a> <f3bg>
# map <f3bg> editText run="move,backward,lineboundary,exec,move,"


mapkey <c-k> <f3rmline>
map <f3rmline> editText run="extend,forward,lineboundary,exec,delete,"

@gdh1995
Copy link
Owner

gdh1995 commented Feb 2, 2020

Then use <a-d:i> instead of <a-d> - :i means it's only for InsertMode.

Doc: https://github.com/gdh1995/vimium-c/wiki/Use-in-another-keyboard-layout (the paragraph of "Since v1.80.1, this directive takes effects in all modes, ")

@parisni
Copy link
Author

parisni commented Feb 2, 2020

perfect !

@parisni
Copy link
Author

parisni commented Feb 3, 2020

Any idea how to mapkey for up/down (appreciable to edit online markdown files for eg)?
I tried those but did not work:

mapkey <c-n:i> <Down>
mapkey <c-p:i> <Up>

@gdh1995
Copy link
Owner

gdh1995 commented Feb 3, 2020

Selection's document is in https://developer.mozilla.org/en-US/docs/Web/API/Selection/modify, and move,backward,line and move,forward,line should work as up/down.

BTW, mapkey only works inside Vimium C, while there's no API to send mapped target keys to browsers or other extensions.

@parisni
Copy link
Author

parisni commented Feb 9, 2020

many thanks

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants