TW5 [NEW plugin] Keyboard shortcuts

1,415 views
Skip to first unread message

Danielo Rodríguez

unread,
Apr 19, 2014, 5:39:09 AM4/19/14
to tiddl...@googlegroups.com
Hello,

I'm glad to present my third plugin. This corresponds to the next week since I will try to deliver just one per week :P

It has some limitations that I expect anyone could help me to eliminate.  

Description

This plugin allows you to use keyboard shortcuts for the most common wikitext markup.

Compatibility

This has been tested with tiddlywiki 5.0.8 and 5.0.9. Since I cant' guarantee retro-compatibility It should work with consecutive releases.

How to install

Just drag and drop the link below to your own tiddlywiki file.

KeyboardSnippets

Usage

While on a text field just try some key combinations. If you have text selected it will be enclosed in the text snipped.

Key combinations

I already defined the most common shortcuts to wiki syntax. Here is a table of what is already available

Combinationsnippetrenders as
ctrl+b'' ''bold
ctrl+i// //italics
ctrl+u __ __underline
ctrl+s,, ,, subscript
ctrl+l*non ordered list
ctrl+o#ordered list
ctrl+kcode
alt+t|| table cell
alt+h|!|table head
alt+s ~~ ~~strikeout

Customization

You can add your own key bindings just editing the file :

$:/plugins/danielo/keyboardSnippets/KEYBINDINGS.

Adding a new entry

You have to respect the formatting of the file. The best way to add a new entry is to copy an existing one and edit it. Every entry has to end in },

The format is one or more key modifiers and a single normal letter in lower case.

Key modifiers

The supported modifiers are: ctrl shift alt . To use more than one modifier you have to do it in that order. Example of valid key combinations are:

  • ctrl+o
  • shift+o
  • ctrl+shift+o
  • ctrl+shift+alt+o

As invalid combinations you can see

  • shift+ctrl+o
  • ctrl+alt+shift+o
  • o+ctrl

Removing customizations

If you mess up with your customizations and you want to restore to default just delete the tiddler:

$:/plugins/danielo/keyboardSnippets/KEYBINDINGS.

Limitations

  • HTML markup is not supported for snippets.
  • Caret ^ is not supported

Hope you enjoy it!!

PMario

unread,
Apr 19, 2014, 7:33:26 AM4/19/14
to tiddl...@googlegroups.com
Nice,

but I think ctrl + s should be not used for any of your default settings.
Most programs use it for a save action.

IMO in TW context ctrl-s should be "save without closing the edit window."

-mario

Danielo Rodríguez

unread,
Apr 19, 2014, 10:43:02 AM4/19/14
to tiddl...@googlegroups.com
Hello Mario,

My plugin overrides the default behavior only when you are typing in a text input.
Anyway, you can always change it via the configuration tiddler.

Alberto Molina

unread,
Apr 19, 2014, 12:41:02 PM4/19/14
to tiddl...@googlegroups.com
Nice plugin, thanks!

Can I suggest the following ?
  • Ctrl+L for links: [[ ]]
  • Ctrl+T for transclusions: {{ }}
Alberto

Danielo Rodríguez

unread,
Apr 19, 2014, 12:51:25 PM4/19/14
to tiddl...@googlegroups.com
Hello Alberto.

Glad you like it.
Of course you can suggest! But even beter: you can edit the KEYBINDINGS tiddler and add your custom key combinations. The suggested combinations are already used for list and tables. Please note that there is no way to differentiate between upper and lower case keys. But you can use "ctrl+alt+l" and "ctrl+alt+t"


Regards.

Matabele

unread,
Apr 19, 2014, 2:54:19 PM4/19/14
to tiddl...@googlegroups.com
Hi

Great work -- I have added a few suggestions that work for me:

{ 
 "ctrl+b" : { "pre":"''", "post":"''"}, 
 "ctrl+i" : { "pre":"//", "post":"//"},
 "ctrl+o" : { "pre":"\n#", "post":" "},
 "ctrl+l" : { "pre":"\n*", "post":" "},
 "ctrl+m" : { "pre":"<<", "post":">>"},
 "ctrl+u" : { "pre":"__", "post":"__"}, 
 "ctrl+k" : { "pre":"\n```\n", "post":"```"}, 
 "ctrl+s" : { "pre":",,", "post":",,"}, 
 "ctrl+alt+t" : { "pre":"{{", "post":"}}"},
 "ctrl+alt+l" : { "pre":"[[", "post":"]]"},
 "alt+w" : { "pre":"<$", "post":"/>"},
 "alt+z" : { "pre":"{{!!", "post":"}}"},
 "alt+t" : { "pre":"|", "post":"|"},
 "alt+h" : { "pre":"|!", "post":"|"},
 "alt+s" : { "pre":"~~", "post":"~~"}

}
regards

Danielo Rodríguez

unread,
Apr 19, 2014, 3:02:12 PM4/19/14
to tiddl...@googlegroups.com
Hi Matabelle.

Great additions.
I think I will add it to the default ones.

Regards.

Matabele

unread,
Apr 19, 2014, 3:45:16 PM4/19/14
to tiddl...@googlegroups.com
Hi

Also:

 "alt+v" : { "pre":"$", "post":"$"},
regards

On Saturday, April 19, 2014 11:39:09 AM UTC+2, Danielo Rodríguez wrote:
Message has been deleted

Leo Staley

unread,
Apr 19, 2014, 8:22:20 PM4/19/14
to tiddl...@googlegroups.com
I still have a very habit of randomly hitting ctrl-s while writing to save my writing. 

Actually, could you make that happen again?

Danielo Rodríguez

unread,
Apr 20, 2014, 1:29:47 AM4/20/14
to tiddl...@googlegroups.com
Hello Leo

Yes, it is possible to use the ctrl+s combination to save changes, but we have to decide in which way.
  • We can raise a save-tiddler message, but that will take you out edit mode
  • We can save the whole wiki, including the shadow tiddler you're editing. But this could be slow in some cases.
I can extend the widget to raise message events and let each user decide.
Regards.

Matabele

unread,
Apr 20, 2014, 2:27:30 AM4/20/14
to tiddl...@googlegroups.com
Hi Danielo

A useful feature of Stephan Hradeck's TW5 bookmarklets (available here) was the way that the ol and ul bookmarklets inserted a # or * at the start of the line for several lines at one time (when several lines are selected.) Your keyboard shortcuts insert a # or * at the beginning of only the first line, even when several lines are selected.

Is there any way of implementing this?

regards

On Saturday, April 19, 2014 11:39:09 AM UTC+2, Danielo Rodríguez wrote:

Danielo Rodríguez

unread,
Apr 20, 2014, 2:36:43 AM4/20/14
to tiddl...@googlegroups.com
Hello Matabele,

Yes it's possible of course. I didn't check Stephan's bookmarklet but it is a single script to do that certain task. I will need a way to distinguish between normal shortcuts and multi-line shortcuts. Maybe adding a third parameter like "multiline:true" for that kind of  situations.

I will try it out, but let me know if you thing this is a good way to accomplish. You don't have to specify multiline on every entry, just on those that actually are.

I'll let you know when it's implemented.

William Jackson

unread,
Apr 20, 2014, 2:47:26 AM4/20/14
to tiddl...@googlegroups.com
Hi Danielo

Thanks, that should be fine -- it's only lists that require a multiline behaviour -- for all other shortcuts this would be pointless.

regards
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/5Wjr_nO7cMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Apr 20, 2014, 6:10:11 AM4/20/14
to tiddl...@googlegroups.com
Hello Matabele.

I just added this hability. Try it out the new version at http://braintest.tiddlyspot.com/ and let me know your toughs.

Regards

Stephan Hradek

unread,
Apr 20, 2014, 6:26:40 AM4/20/14
to tiddl...@googlegroups.com
Why not make this regular expression aware? Yes… I'm a regular expression junkie…

Instead of specifying pre and post make:

"alt+t" : [ { search: /^|  +|$/gm, replace:"|" } ],
"ctrl+o" : [ { search: /^ */gm, replace:"# " } ],

Why did I specify an array? That way you can specify more than one search and replace pattern for each keypress. All the search and replaces should be executed one after the other.

The alt+t could alternatively be specified like this:

"alt+t" : [ { search:/^/gm, replace:"|" }, { search:/  +/g, replace:"|" }, { search:/$/gm, replace:"|" } ]





Danielo Rodríguez

unread,
Apr 20, 2014, 7:17:54 AM4/20/14
to tiddl...@googlegroups.com
Hello Stephan.

I'm not very fan of the regular expressions. They are hard to read, they are hard to write and you can get unexpected behaviors. I want to keep the syntax simple. That way any user can write their own entries. 

Anyway. Could you explain your idea a bit more? What are the advantages of your idea? I don't understand at all what this does:

"alt+t" : [ { search:/^/gm, replace:"|" }, { search:/  +/g, replace:"|" }, { search:/$/gm, replace:"|" } ]

Regards

Devin Weaver

unread,
Apr 20, 2014, 8:59:25 AM4/20/14
to tiddl...@googlegroups.com
I was thinking something similar. I'm a keyboard junkie (VIM addict) and it irks me to lift my hand from the keyboard to the mouse just to navigate. Sure wish there was some keyboard shortcuts for edit (pencil button), cancel edit (circle X button), save editing (Check mark button), search field focus, maybe one for closing a tiddler (hiding a tiddler from view), and let me not forget new tiddler.

The new tiddler one would be super helpful. I love how I can just write something and TiddlyWiki picks it up as a link to a missing tiddler that I can click and immediately start editing. However, most work flows as me editing a tiddler and inspiration hits and I need to finish the current thought in a new tiddler then return to the original one. This means pressing the new tiddler button. Again some keyboard shortcuts would speed this process up immensely.

Danielo Rodríguez

unread,
Apr 20, 2014, 10:26:27 AM4/20/14
to tiddl...@googlegroups.com
Hello Devin,

All those shortcuts (except for the edit and the close ones) are possible thanks to the official keyboard widget.

You can define wiki messages as reaction to a limited set of keys. 

For example for new tiddler you can enclose your story river inside one keyboard widget and set the message param to tw-new-tiddler.

There is one already defined for saving the current tiddler. cntrl+enter is like hitting the check mark button. I use it all the time. You can use it as a base to define your cancel edit

Give it a try.

Danielo Rodríguez

unread,
Apr 20, 2014, 10:31:43 AM4/20/14
to tiddl...@googlegroups.com
Regarding my own plugin

I just added the ability to navigate between table cells using "ctr+right_arrow"

It is very useful for me. Is it useful for anyone else?
I have plans to add shortcuts for clone current line too. More ideas?

Stephan Hradek

unread,
Apr 20, 2014, 10:58:21 AM4/20/14
to tiddl...@googlegroups.com


Am Sonntag, 20. April 2014 13:17:54 UTC+2 schrieb Danielo Rodríguez:
They are hard to read,

Not in general. They can be hard to read..
 
they are hard to write

Not in general. Just for thse who do not yet understand them ;)
 
and you can get unexpected behaviors.

You can get unexpected behaviour all the time you do something on a computer.
 
I want to keep the syntax simple.

Great! Regexp syntax is simpl :D (just kidding - a bit)
 
That way any user can write their own entries. 

That's why I propose regexp. That way any user - who understands regexps - can write even more powerful shortcuts.
 
Anyway. Could you explain your idea a bit more? What are the advantages of your idea? I don't understand at all what this does:

Sure:
 
"alt+t" : [ { search:/^/gm, replace:"|" }, { search:/  +/g, replace:"|" }, { search:/$/gm, replace:"|" } ]

The idea is, that the alt+t handler finds an array of objects. It then executes the instructions in each of the array elements. So it searches in the tiddler or in the selected range for the regular expression given under "search" and replaces the matches with the string given under "replace".

/^/gm means: Search for the start of the line (g=search globally, meaning, search the whole range. m=consider the range to consist of multiple lines)

/  +/g means: Search for any space followed by a sequence of 1 or more (+) spaces, so search for at least 2 spaces.

/$/gm means: Search for the end of the line. g and m is explained above.

So what this would do is to first search for all linestarts and out a | there. Then it would search for all sequences of 2 or more spaces and replace them with a pipe. Last it would put a pipe at the end of each line.

Matabele

unread,
Apr 20, 2014, 11:52:40 AM4/20/14
to tiddl...@googlegroups.com
Hi Danielo

The new functionality for lists works exactly as expected on your website -- v.5.0.8. However, when I copy to a v.5.0.10 it appears to revert to the old behaviour.

regards

On Saturday, April 19, 2014 11:39:09 AM UTC+2, Danielo Rodríguez wrote:

Danielo Rodríguez

unread,
Apr 20, 2014, 12:12:34 PM4/20/14
to tiddl...@googlegroups.com
Hello Matabele,

I have the plugin installed in my own personal wiki (5.0.10) and I have tried in a brand new one too. It works as expected.
Did you saved an reload your wiki? Sounds like you still using the cached version.

Regards.

Matabele

unread,
Apr 20, 2014, 12:18:36 PM4/20/14
to tiddl...@googlegroups.com
Hi Danielo

The new functionality for lists works exactly as expected on your website -- v.5.0.8. However, when I copy to a v.5.0.10 it appears to revert to the old behaviour.

regards

On Saturday, April 19, 2014 11:39:09 AM UTC+2, Danielo Rodríguez wrote:

Danielo Rodríguez

unread,
Apr 20, 2014, 12:19:28 PM4/20/14
to tiddl...@googlegroups.com
Hello Stephan,


Not in general. They can be hard to read..

Not in general. Just for thse who do not yet understand them ;)
 
I disagree, they are hard in any way :P
 
 

You can get unexpected behaviour all the time you do something on a computer.


Usually in the 8th layer.

 
Great! Regexp syntax is simpl :D (just kidding - a bit)
 
Hahahah
 
 

That's why I propose regexp. That way any user - who understands regexps - can write even more powerful shortcuts.
  
So what this would do is to first search for all linestarts and out a | there. Then it would search for all sequences of 2 or more spaces and replace them with a pipe. Last it would put a pipe at the end of each line.

Ok. I agree to add this feature as "optional". But the syntax should vary because the JSON encode limitations, so it should be like:

"alt+t" : [ { "exp":"^", "modifiers": "gm" , "replace":"|" } , ......

I tried and it is very powerful since you can create a single cell o a full table, depending on your selection. Since you are more regexp skilled... could you think in possible side effects?

Thank you for your suggestion. I will implement it very soon.

Matabele

unread,
Apr 20, 2014, 12:43:54 PM4/20/14
to tiddl...@googlegroups.com
Hi Danielo

OK - many thanks. Tested it with a brand new 5.0.10 and works exactly as expected.

regards

Danielo Rodríguez

unread,
Apr 21, 2014, 10:40:36 PM4/21/14
to tiddl...@googlegroups.com
Hello Stephan,

I just added the ability to interpret regular expressions. It is not deployed yet. I would like to simplify the syntax a little bit. Currently It's a bit ugly and the code to parse it is messy in my opinion. Could you help me to define a better syntax? 

Regards.

Shash

unread,
May 2, 2014, 11:35:06 AM5/2/14
to tiddl...@googlegroups.com
Hello,

Thanks for the above. I am looking for a few more shortcuts especially for the below

  • Closing a tiddler after edits
  • Saving TW as a whole. 
Shash

Danielo Rodríguez

unread,
May 2, 2014, 2:09:00 PM5/2/14
to tiddl...@googlegroups.com
Hello Shash,

Glad you liked it.
What do you mean with closing a tiddler after edits? In edit mode you can type ctrl+enter and it will save current tiddler.
For saving the whole wiki you can use the current keyboard widget(not mine but the official one). But you need to edit the body of TW and modify the keyboard widget itself. I have to admit that it is tricky.

But my plugin's shortcuts are bind to the text area you are in. So it only reacts when you are typing inside a text area, so those shortcuts does not make sense.

Måns

unread,
May 3, 2014, 6:06:31 AM5/3/14
to tiddl...@googlegroups.com
Hi Danielo

Thank you very much for your work on Keyboard Shortcuts plugin.
One of the things that I really missed from TWC was Eric's QuickEdit toolbar. This seems to be an almost complete replacement to me.

A couple of features I still miss (which I use very often in TWC) is the search and replace (- all, - this, -find next target -replace this and find next target)


Eric's SplitTiddler allows you to set up different rules how to split text content into new tiddlers and creates an index of created tiddlers  (similar to what happens when you drop several files on a tw5)

I don't expect that your keyboard shortcuts plugin should be able to handle all those things - however imo it might be very usefull if a shortcut could open a dialog from a plugin like Eric's replace or SplitTiddler plugins, and let the user interact/ make consecutive actions on selected text.... (just a thought...)

Another thought I had was that it might be very usefull to have an optional little (yet another keyboard shortcut or a "simple" rightclick in editmode?) popup with keyboard shortcut info available. Eric's quickedittoolbar is very helpfull for someone who are learning wikitext markup because it is visual at all times. Maybe a popup for the keyboard shortcuts could help beginners learn/remember wikitext?

Thanks again - Great job!

Cheers Måns Mårtensson

Danielo Rodríguez

unread,
May 4, 2014, 1:32:15 PM5/4/14
to tiddl...@googlegroups.com
Hello Mans


"Another thought I had was that it might be very usefull to have an optional little (yet another keyboard shortcut or a "simple" rightclick in editmode?) popup with keyboard shortcut info available. Eric's quickedittoolbar is very helpfull for someone who are learning wikitext markup because it is visual at all times. Maybe a popup for the keyboard shortcuts could help beginners learn/remember wikitext?"


I also though about that. It is definitively my next step. Even using it by myself I experienced those doubts. I thought to use a tiddlywiky message. Like the saved wiki. Have you thought something different? How do you think it's better? A key shortcut or right mouse button click? Maybe a help button?

Måns

unread,
May 4, 2014, 7:14:23 PM5/4/14
to tiddl...@googlegroups.com
Hi Danielo


 I thought to use a tiddlywiky message. Like the saved wiki. Have you thought something different?

A notification/message like box might work - I don't think it interferes with/takes over mousehandling from selected text .. - or does it?
  

How do you think it's better? A key shortcut or right mouse button click? Maybe a help button?

A keyboardshortcut "to rule them all ..." - hmm. Maybe Ctrl + F1? - Is that a possible combination?
If you don't remember the keyboard button combination you need - at least you'll need to be able to remember the combination that will show the list of available keyboard shortcuts.... It should be so simple/standard that you might guess it - without even knowing what it is...

If you create a "help-button" (especially for keyboard shortcuts) - next feature request might be that users would like to have individual buttons for each and every available shortcut > a full toolbar....- which might defeat the whole purpose of using keyboard shortcuts in the first place...

Imho - It would be very nice to have both options (keyboard shortcuts and an optional toolbar) - letting users choose whether they want see the toolbar (with buttons for each individual function) - or if they just want to use keyboard shortcuts - and call a "reminder message box" with yet another shortcut, if they need it...

Please forgive that I fantasize about a toolbar - if you think it is an overkill for your keyboard shourtcuts plugin.

Cheers Måns Mårtensson
 

Matabele

unread,
May 4, 2014, 9:18:53 PM5/4/14
to tiddl...@googlegroups.com
Hi

I would suggest that an editable pop-up help is preferable to a pop-up toolbar. Both provide help when the user has forgotten a less familiar shortcut, but the first approach promotes learning, whilst the second doesn't. Also - an editable help could be used for any reminder the user might wish for (other useful keyboard shortcuts, for example) - a pop-up toolbar would be restricted to only your plugin shortcuts.

regards

Matabele

unread,
Jun 22, 2014, 12:35:22 AM6/22/14
to tiddl...@googlegroups.com
Hi Danielo

The new select widget gave me an idea for your keyboard shortcuts plugin. Would it not be possible to make a new 'Format' button for the edit control panel in the form of a select widget which applies the chosen formatting to any selected text? (i.e. a select format drop-down instead-of/as-well-as keyboard shortcuts)  

Danielo Rodríguez

unread,
Jun 23, 2014, 10:44:13 AM6/23/14
to tiddl...@googlegroups.com
Hello Matabelle

Yes, It is possible. But my plans for this plugin are going in a different way. I want to add a button for each "common" format. I made some test about it and I think I'm in the good way.
But, if anyone prefers just a drop down there is nothing to avoid me to make it configurable.

Regards.

Matabele

unread,
Jun 23, 2014, 11:10:29 AM6/23/14
to tiddl...@googlegroups.com
Hi Danielo

Perhaps a bit of both is the answer -- a few individual buttons for selected formats, and a dropdown for the reminder.

regards

Dominik P.

unread,
May 28, 2017, 12:24:51 PM5/28/17
to TiddlyWiki
hi

is this working in 5.1.13?
when i try to drag n drop it it says import untitled
 
my need:
i want a shortkey for just inserting [[ ]] around selected text without the create link dialog
any suggestions?

thanks

Birthe C

unread,
May 28, 2017, 1:02:08 PM5/28/17
to TiddlyWiki
Hi Dominik,

I do realise you are asking for at shortcut. But maybe you would like this. http://skplugins.tiddlyspot.com/#%24%3A%2Fplugins%2Fsk%2FLinks


Birthe

Danielo Rodríguez

unread,
May 30, 2017, 5:08:18 AM5/30/17
to TiddlyWiki
I works on 5.1.14 for me.

Where are you picking it from? You should try from 

Dominik P.

unread,
May 30, 2017, 6:45:58 AM5/30/17
to tiddl...@googlegroups.com
@
Birthe thanks i have that one integrated in the node.js version by default i guess, but not what i was looking for

@Danielo thanks, now it is magically working :D maybe i just dragged the link from the post or something

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/5Wjr_nO7cMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/40baf995-b65d-478e-9132-7bcf5795ae2b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Dominik P.

unread,
May 30, 2017, 7:06:18 AM5/30/17
to TiddlyWiki
but i guess it conflicts with my following default toolbar:




does anyone know where to modify it?

Ton Gerner

unread,
May 30, 2017, 7:16:01 AM5/30/17
to TiddlyWiki
Hi Dominik,

The editor toolbar uses an iframe for editing which means that Danielo's keyboard shortcuts (and also bookmarklets) don't work when the toolbar is visible.

See my Bookmarklets guide for a solution/workaround.

Cheers,

Ton

Reply all
Reply to author
Forward
0 new messages