lambdalisue / jupyter-vim-binding

Jupyter meets Vim. Vimmer will fall in love.
2.1k stars 136 forks source link

Remap Ctrl-a to select-all binding #24

Closed wilzbach closed 8 years ago

wilzbach commented 8 years ago

As accessing the system clipboard for yanking (#4), this adds/hacks the missing ability to use ctrl-a in CodeMirror's Vim mode to select the entire content of a cell.

I personally find it also very hand to map this to the key a in the normal vim mode - if you agree we could add the following snippet to the commands mapping:

// maps the key "a" to a defined function, e.g. selectAll 
CodeMirror.Vim.defineAction("selectall",selectAll);
CodeMirror.Vim.mapCommand("a", "action", "selectall", {}, {context: "normal"}); 
lambdalisue commented 8 years ago

As accessing the system clipboard for yanking (#4), this adds/hacks the missing ability to use ctrl-a in CodeMirror's Vim mode to select the entire content of a cell.

I don't really get. As far as I know, Ctrl-a stands for to increase the integer under the cursor in Vim and it works in CodeMirror as well. So I don't really think I should remap it while the key have a feature.

Additionally, to select all content, I think ggVG is a standard way in Vim. That mean you actually don't need to create an action, the following custom.js would work I guess (I haven't test though).

// Configure CodeMirror
require(['codemirror/keymap/vim'], function() {
  // Ctrl-a to select all content
  CodeMirror.Vim.map("<C-a>", "ggVG", "normal");
});
wilzbach commented 8 years ago

I don't really get.

Yes this was just about a more convenient way for ggVG ;-)

Ctrl-a stands for to increase the integer under the cursor in Vim and it works in CodeMirror as well. So I don't really think I should remap it while the key have a feature.

Didn't know that - sorry about this. I will make a PR to the README about this

lambdalisue commented 8 years ago

I will make a PR to the README about this

Well, probably you don't need. There are tons of features and I cannot list all. If you desire, you can use https://github.com/lambdalisue/jupyter-vim-binding/wiki to share tips of jupyter-vim-binding :-)

lambdalisue commented 8 years ago

And let me know if CodeMirror.Vim.map("<C-a>", "ggVG", "normal"); works. I just wonder ;)

wilzbach commented 8 years ago

yes it does & I started the wiki :)

lambdalisue commented 8 years ago

Thanks a lot !