在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:lambdalisue/jupyter-vim-binding开源软件地址:https://github.com/lambdalisue/jupyter-vim-binding开源编程语言:JavaScript 98.8%开源软件介绍:jupyter-vim-bindingDo you use Vim? And you need to use Jupyter Notebook? This is a Jupyter Notebook (formerly known as IPython Notebook) extension to enable Vim like environment powered by CodeMirror's Vim. I'm sure that this plugin helps to improve your QOL. This extension stands for providing a Vim like environment, so it would drastically overwrite the default mappings and introduce new behaviors. For example
Need contributorsWhile I changed my job, I don't use jupyter notebook, and I can't make enough time to maintain this plugin. So if you like this plugin, please consider being a contributor. InstallationThere are several ways to install the extension, see Installation for detail. The procedure below is the most simple one for quick use (A recommended way is different from this. See the link above if you are a beginner.) # Create required directory in case (optional)
mkdir -p $(jupyter --data-dir)/nbextensions
# Clone the repository
cd $(jupyter --data-dir)/nbextensions
git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding
# Activate the extension
jupyter nbextension enable vim_binding/vim_binding UsageThis extension provides Jupyter mode (For manipulating Jupyter) and Vim mode (For manipulating text). In Vim mode, there is Command mode and Insert mode like native Vim. Users can distinguish these modes by the background color of the cell. Key mappings are designed for Vimmer so probably you don't need to know much about the mapping but remember the followings to survive:
You can find detailed information about the mappings or concept in Concept page. Completion and Tooltipjupyter-vim-binding supports When the user hits When user hit Note that you can repeat Plug mappingsjupyter-vim-binding provides the following
While CodeMirror's Vim does not provide CustomizationTo customize key mappings in Vim mode, you need to understand that there are two kinds of mappings in this extension:
To customize mappings provided by CodeMirror's Vim, create a // Configure CodeMirror Keymap
require([
'nbextensions/vim_binding/vim_binding', // depends your installation
], function() {
// Map jj to <Esc>
CodeMirror.Vim.map("jj", "<Esc>", "insert");
// Swap j/k and gj/gk (Note that <Plug> mappings)
CodeMirror.Vim.map("j", "<Plug>(vim-binding-gj)", "normal");
CodeMirror.Vim.map("k", "<Plug>(vim-binding-gk)", "normal");
CodeMirror.Vim.map("gj", "<Plug>(vim-binding-j)", "normal");
CodeMirror.Vim.map("gk", "<Plug>(vim-binding-k)", "normal");
});
// Configure Jupyter Keymap
require([
'nbextensions/vim_binding/vim_binding',
'base/js/namespace',
], function(vim_binding, ns) {
// Add post callback
vim_binding.on_ready_callbacks.push(function(){
var km = ns.keyboard_manager;
// Allow Ctrl-2 to change the cell mode into Markdown in Vim normal mode
km.edit_shortcuts.add_shortcut('ctrl-2', 'vim-binding:change-cell-to-markdown', true);
// Update Help
km.edit_shortcuts.events.trigger('rebuild.QuickHelp');
});
}); If you would like to customize the design, create a your /* Jupyter cell is in normal mode when code mirror */
.edit_mode .cell.selected .CodeMirror-focused.cm-fat-cursor {
background-color: #F5F6EB !important;
}
/* Jupyter cell is in insert mode when code mirror */
.edit_mode .cell.selected .CodeMirror-focused:not(.cm-fat-cursor) {
background-color: #F6EBF1 !important;
} See Customization to find useful snippets. Don't be afraid to share your snippets at that page ;-) Limitationjupyter-vim-binding has the following technical limitation. If anybody knows about a confirmed workaround for these limitations, let me know. Google ChromeGoogle Chrome prohibits javascript from overriding several key mappings such as
VivaldiThe chromium-based Vivaldi browser provides more flexibility in key mapping customizations and might be a viable alternative to Google Chrome for power users.
In contrast to Google Chrome or Chromium, (almost) all keyboard shortcuts in Vivaldi can be changed or disabled, including (but not limited to) Furthermore, Vivaldi allows assigning a keyboard shortcut to temporarily disable all other browser keyboard shortcuts, making all key mappings available for other uses.
Note that this temporary change applies globally to all tabs and windows of the browser instance (or "Profile") under consideration. To confine it to a subset of tabs, use a separate profile via the ClipboardMost modern browsers prohibit javascript from accessing a system clipboard without user action, such as clicking a button.
Because of this, there is no chance to enable copy and paste through The followings are clipboard library for javascript, but all of them require What we need is a LicenseThe MIT License (MIT) Copyright (c) 2015-2016 Alisue, hashnote.net Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论