How to use the Edit/add new keyboard shortcuts in Jupyter - jupyter-notebook

I am in the Edit Command mode Shortcuts dialog and things seem reasonable ..
But the actual behavior is a different story
When using the Option modifier (plus a non-modifier key) it just ends up printing a high-ascii character value in the add shortcut area .. and then when I refresh the page it has gone away.
I can not get Command modifier (plus a non-modifier key) to work at all. It is jus ignored.
The Control modifier (plus any key) is completely ignored.
So there is a basic usability misunderstanding here. Advice appreciated.

I added 'Ctrl-Q' as a shortcut to restart kernel and run all the cells. You can see the picture below. It is working fine. In the 'Ctrl-Q', 'Q' was just lowercase and it ran successfully.

Related

Return Key in Edit Command Mode Shortcuts - Jupyter Notebook

While willing to write ↩a as a new shortcut for the run all cells above command I could not find how to specify the return symbol in Jupyter Notebook.
Writing return-a or ↩-ain the Edit Command Mode does not work and the modifier is not specified in the help dialog.
Any idea?
Return is not a modifier so shortcut like ↩-a make little sens (pressing enter and A at the same time. ↩,a meaning Return key followed by A key make more sens, but Enter is so pervasive for many actions that it is not usable in user shortcuts. I would suggest you to open an issue on jupyter/notebook on GitHub to ask for return to be added as a convenient way to map to ↩ , though even if we do that we can't guaranty that it will work. If you are willing to try to code that yourself, have a look at keyboard.js, the mapping from enter to displaying ↩ is already done in quickhelp.js, for mac at least.

Vimperator: Follow hint in new tab and switch to it

I am trying to find a strategy in the Vimperator-logic for opening a link to a new tab and switch to it immediately.
I guess this might be a TMTOWTDI.
My first approach would be to start off with a :command sequence. Unfortunately F - Follow hint in background tab - has no equivalent in the command mode. The best solution for me would be without any change in default behaviour whatsoever.
Another approach might be to combine the default F with switching to next tag gt. This would have to include to pass the parameter for F, say 10 for the tenth link of the document. Unfortunately F10gt does open the tenth link but without switching to the newly opened tab.
A third approach does come to mind when using focus elements: ;y10 yank the destination link, :tabopen + paste clipboard content.
Any ideas of what is doable and the easiest?
This functionality exists as a mode of the hint function. Pressing ;t
will produce the desired result. If you want to map it you can also access the javascript directly.
:js hints.show("t")

see variable definition by tooltips in vim

I need to frequently check definitions of variables/functions. I can jump to definitions of variables/functions by ctags with gd,gD, ctrl ] etc.
But by it, I jump from my current position and lose context of current position. Is there any way I can check definitions in tool tips like we see in ctrl p ctrl n in insert mode. It would really help in quickly understand and browsing code.
Thanks,
Supposing you already have an up-to-date and reachable tags file, you can see the definition of the variable or method under your cursor in a preview window with:
<C-w>}
See :h preview-window.

Unable to modify re-opened files in vim(file permissions not a problem)

I am working with vim. I created a new cpp file using
vim xyz.cpp
After opening the file, I added some basic includes and comments. Then I closed it(:wq!) and re-opened it only to find that I am not able to delete/edit the previously written commands, even after pressing i (for insert), although it gets into insert mode and I am able to add new text to the file. I must say that when i am NOT in the insert mode, then I am able to delete individual characters by pressing x . But it doesnt solve my problem.
I checked the file permissions and it says -rwxrwxrwx, so I dont think permissions is the issue. Has anyone faced this problem before. Any kind of help will be appreciated.
Thanks
:help 'backspace' is your friend
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
mode. This is a list of items, separated by commas. Each item allows
a way to backspace over something:
value effect ~
indent allow backspacing over autoindent
eol allow backspacing over line breaks (join lines)
start allow backspacing over the start of insert; CTRL-W and CTRL-U
stop once at the start of insert.
When the value is empty, Vi compatible backspacing is used.
Try to set it to
set backspace=indent,eol,start

What determines sorting of files in a QFileDialog?

Users open files in our app through a QFileDialog. The order of the filenames is bizarre. What is determining the sorting order, and how can we make it sort by filenames, or otherwise impose our own sorting, perhaps giving it a pointer to our own comparison function?
The documentation and online forums haven't been helpful. Unless it's well hidden, there doesn't seem to be any sorting method, property, etc.
This is a primarily Linux app, but also runs on Macs. (I know nothing about Mac.)
Here is the juicy part of the source code:
QtFileDialog chooser(parent, caption, directory, filter);
/// QtFileDialog is our class derived from QFileDialog
chooser.setModal(true);
chooser.setAcceptMode(acceptMode);
chooser.setFileMode(fileMode);
QStringList hist = chooser.history();
chooser.setHistory(hist);
/* point "x" */
if(chooser.exec()) {
QStringList files = chooser.selectedFiles();
...blah blah blah...
From one of the answers, I tried an evil experiment, adding this ill-informed guesswork code at "point x":
QSortFilterProxyModel *sorter = new QSortFilterProxyModel();
sorter->sort(1); // ???
chooser.setProxyModel(sorter);
But this crashed spectacularly at a point about 33 subroutine calls deep from this level of code. I admit, even after reading the Qt4 documentation and sample code, I have no idea of the proper usage of QSortFilterProxyModel.
Are you using QFileDialog by calling exec()? If you are, you should have a button to switch the view to Detail View. This will give you some column headers that you can click on to sort the files. It should remember that mode the next time the dialog opens but you can force it by calling setViewMode(QFileDialog::Detail) before calling exec().
An alternative is to call the static function QFileDialog::getOpenFileName() which will open a file dialog that is native to the OS on which you are running. Your users may like the familiarity of this option better.
Update 1:
About sort order in screen cap from OP:
This screen capture is actually showing a sorted list. I don't know if the listing behaviour is originating from the Qt dialog or the underlying file system but I know Windows XP and later do it this way.
When sorting filenames with embedded numbers, any runs of consecutive digits are treated as a single number. With the more classic plain string sorting, files would be sorted like this:
A_A_10e0
A_A_9a05
Going character by character, the first 1 sorts before the 9.
.. But with numerical interpretation (as in Windows 7 at least), they are sorted as:
A_A_9a05
A_A_10e0
The 9 sorts before the 10.
So, the sorting you are seeing is alphabetical with numerical interpretation and not just straight character by character. Some deep digging may be required to see if that is Qt behaviour or OS behaviour and whether or not it can be configured.
Update 2:
The QSortFilterProxyModel will sort the strings alphabetically by default so there is not much work to using it to get the behavior you are looking for. Use the following code where you have "point x" in your example.. (you almost had it :)
QSortFilterProxyModel *sorter = new QSortFilterProxyModel();
sorter->setDynamicSortFilter(true); // This ensures the proxy will resort when the model changes
chooser.setProxyModel(sorter);
I think what you need to do is create a QSortFilterProxyModel which you then set in your QFileDialog with QFileDialog::setProxyModel(QAbstractProxyModel * proxyModel)
Here are some relevant links to the Qt 4.6 docs about it.
http://doc.trolltech.com/4.6/qfiledialog.html#setProxyModel
http://doc.trolltech.com/4.6/qsortfilterproxymodel.html#details
I don't think it depends upon the implementation of Qt libraries... But upon the Native OS implementation..
For example in Windows,
if you use QFileDialog, it will display the Files and Directories by Name sorted.. It is the same when used in other applications. In the sense that, if you try to open a file through MS- Word, it indeed displays the Files and directories as Name sorted by default..
And am not sure about other environments since am not used to them...
But in Windows, you can change the sorted order by right-click in the area of Files and Directories display and can select the options you like.. For e.g like Name,size,type, modified... And also which is similar, when you use an MS-Word application...
So, I believe it does depend on the Native OS implementation and not on QFileDialog's...

Resources