Closed galou closed 7 years ago
Do you want new operator?why issue subject saying documentation-improve?(its confuse me).
Also what is your usecase if this new operator. You alrady can do 'i then char then escape' to prepare temporal insert-char edit-session you can repeat it by . command.
I guess vim-mode-plus does not need to be altered to implement this new function, that's why it's more about documenting how to implement it as a user.
My use case is exactly this, replace 3 key strokes by 2. I never used spaces in normal mode in vim and bound it this function, which I happen to use quite a lot.
OK, you want documentation on WIki, will update and put link here.
see this wiki, count supported.
If you map it _
, 3 _ a
insert aaa
at cursor position.
Excellent! Thanks!
An update of atom or vim-mode-plus rendered the InsertCharacter
documented at the wiki non functional
Could you please have a look at it? Thanks a lot!
Gaël
PS: For some reason, vim-mode-plus doesn't update anymore on my version of atom.
Atom : 1.21.1 Electron: 1.6.15 Chrome : 56.0.2924.87 Node : 7.4.0 vim-mode-plus: 1.16.0
Your Atom is too old to update to latest vmp.
You can check by finding engines
in pkg.json.
And what's the issue?
InsertCharacter
once worked and now become un-functional?
Or you cannot make it work from the beginning?
What a quick answer! Thanks!
I have
"engines": {
"atom": "^1.19.0"
},
InsertCharacter
worked back in October'17. I can't remember when it stopped working. The issue is:
[Enter steps to reproduce:]
Atom: 1.21.1 x64 Electron: 1.6.15 OS: Ubuntu 14.04.5 Thrown From: vim-mode-plus package 1.16.0
Uncaught TypeError: Cannot read property 'repeat' of null
At /home/gael/.atom/packages/vim-mode-plus/lib/operation-stack.js:157
TypeError: Cannot read property 'repeat' of null
at InsertCharacter.mutateSelection (/home/gael/.atom/init.js:31:66)
at InsertCharacter.mutateSelections (/packages/vim-mode-plus/lib/operator.js:267:12)
at /packages/vim-mode-plus/lib/operator.js:280:37
at TextBuffer.module.exports.TextBuffer.transact (/opt/atom/resources/app/node_modules/text-buffer/lib/text-buffer.js:952:24)
at TextEditor.module.exports.TextEditor.transact (/opt/atom/resources/app/src/text-editor.js:1673:32)
at InsertCharacter.startMutation (/packages/vim-mode-plus/lib/operator.js:261:17)
at InsertCharacter.execute (/packages/vim-mode-plus/lib/operator.js:279:10)
at OperationStack.execute (/packages/vim-mode-plus/lib/operation-stack.js:193:33)
at OperationStack.process (/packages/vim-mode-plus/lib/operation-stack.js:186:12)
at OperationStack.run (/packages/vim-mode-plus/lib/operation-stack.js:102:14)
at /packages/vim-mode-plus/lib/base.js:329:45)
at CommandRegistry.handleCommandEvent (/opt/atom/resources/app/src/command-registry.js:381:36)
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/opt/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/opt/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/opt/atom/resources/app/src/window-event-handler.js:100:42)
at HTMLDocument.<anonymous> (/opt/atom/resources/app/src/window-event-handler.js:3:65)
-0:19.8.0 vim-mode-plus-user:insert-character (input.hidden-input)
-0:19.5.0 vim-mode-plus:set-input-char-space (input.hidden-input)
-0:06.6.0 vim-mode-plus-user:insert-character (input.hidden-input)
-0:03.8.0 vim-mode-plus:set-input-char-f (input.hidden-input)
autocomplete-paths 2.12.1
autocomplete-python 1.10.5
document-outline 1.6.18
ex-mode 0.18.0
file-icons 2.1.15
git-plus 7.10.0
git-time-machine 1.5.9
go-config 1.2.4
go-get 2.1.1
go-hyperclick 1.1.2
Hydrogen 2.2.0
hyperclick 0.1.5
hyperclick-markdown 0.2.2
hyperlink-hyperclick 1.3.4
js-hyperclick 1.12.2
jupyter-notebook 0.0.10
kite 0.58.0
language-diff 0.7.0
language-latex 1.1.1
language-nxc 3.6.1
language-restructuredtext 1.1.0
language-weave 0.4.2
latextools 0.8.5
navigator-go 1.1.3
open-vim 0.2.3
path-hyperclick 0.3.0
pdf-view 0.61.0
preview-inline 1.5.0
python-indent 1.1.4
python-isort 0.0.7
python-mrigor 2.1.3
python-tools 0.6.9
rst-preview 1.3.1
rst-preview-pandoc 0.1.12
split-diff 1.5.1
table-editor 0.2.2
toggler 0.3.1
vim-mode-plus 1.16.0
and
[Enter steps to reproduce:]
Atom: 1.21.1 x64 Electron: 1.6.15 OS: Ubuntu 14.04.5 Thrown From: vim-mode-plus package 1.16.0
Uncaught TypeError: Cannot read property 'isReady' of undefined
At /home/gael/.atom/packages/vim-mode-plus/lib/operation-stack.js:179
TypeError: Cannot read property 'isReady' of undefined
at OperationStack.process (/packages/vim-mode-plus/lib/operation-stack.js:179:13)
at InsertCharacter.processOperation (/packages/vim-mode-plus/lib/base.js:102:34)
at onConfirm (/packages/vim-mode-plus/lib/base.js:140:14)
at CompositeDisposable.onDidSetInputChar.char (/packages/vim-mode-plus/lib/vim-state.js:482:9)
at Function.module.exports.Emitter.simpleDispatch (/opt/atom/resources/app/node_modules/event-kit/lib/emitter.js:25:20)
at Emitter.module.exports.Emitter.emit (/opt/atom/resources/app/node_modules/event-kit/lib/emitter.js:141:34)
at VimState.emitDidSetInputChar (/packages/vim-mode-plus/lib/vim-state.js:214:18)
at /packages/vim-mode-plus/lib/main.js:186:14)
at /packages/vim-mode-plus/lib/main.js:199:28)
at CommandRegistry.handleCommandEvent (/opt/atom/resources/app/src/command-registry.js:381:36)
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/opt/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/opt/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/opt/atom/resources/app/src/window-event-handler.js:100:42)
at HTMLDocument.<anonymous> (/opt/atom/resources/app/src/window-event-handler.js:3:65)
-1:30.6.0 vim-mode-plus-user:insert-character (input.hidden-input)
-1:30.4.0 vim-mode-plus:set-input-char-space (input.hidden-input)
-1:17.5.0 vim-mode-plus-user:insert-character (input.hidden-input)
-1:14.7.0 vim-mode-plus:set-input-char-f (input.hidden-input)
autocomplete-paths 2.12.1
autocomplete-python 1.10.5
document-outline 1.6.18
ex-mode 0.18.0
file-icons 2.1.15
git-plus 7.10.0
git-time-machine 1.5.9
go-config 1.2.4
go-get 2.1.1
go-hyperclick 1.1.2
Hydrogen 2.2.0
hyperclick 0.1.5
hyperclick-markdown 0.2.2
hyperlink-hyperclick 1.3.4
js-hyperclick 1.12.2
jupyter-notebook 0.0.10
kite 0.58.0
language-diff 0.7.0
language-latex 1.1.1
language-nxc 3.6.1
language-restructuredtext 1.1.0
language-weave 0.4.2
latextools 0.8.5
navigator-go 1.1.3
open-vim 0.2.3
path-hyperclick 0.3.0
pdf-view 0.61.0
preview-inline 1.5.0
python-indent 1.1.4
python-isort 0.0.7
python-mrigor 2.1.3
python-tools 0.6.9
rst-preview 1.3.1
rst-preview-pandoc 0.1.12
split-diff 1.5.1
table-editor 0.2.2
toggler 0.3.1
vim-mode-plus 1.16.0
I will fully understand if you don't want to solve this minor issue on an outdated system.
Why you don't update Atom? Which allows you to update vmp to the latest, might solve your issue too.
Ubuntu 14.04 decided not to update Atom anymore, I guess. I use http://ppa.launchpad.net/webupd8team/atom/ubuntu
.
http://flight-manual.atom.io/getting-started/sections/installing-atom/#platform-linux then go to #debian-and-ubuntu-debapt section
Read this, and try, also you can download latest deb pkg directly.
Thanks for the tip!
So I now have Atom 1.23.1 and vmp 1.24.4 but the issue is still present:
[Enter steps to reproduce:]
InsertCharacter
as specified in the wiki.space
for exampleAtom: 1.23.1 x64 Electron: 1.6.15 OS: Ubuntu 14.04.5 Thrown From: vim-mode-plus package 1.24.4
Uncaught TypeError: Cannot read property 'repeat' of null
At /home/gael/.atom/packages/vim-mode-plus/lib/operation-stack.js:151
TypeError: Cannot read property 'repeat' of null
at InsertCharacter.mutateSelection (/home/gael/.atom/init.js:31:66)
at InsertCharacter.mutateSelections (/packages/vim-mode-plus/lib/operator.js:261:12)
at InsertCharacter.execute (/packages/vim-mode-plus/lib/operator.js:289:35)
at OperationStack.execute (/packages/vim-mode-plus/lib/operation-stack.js:187:33)
at OperationStack.process (/packages/vim-mode-plus/lib/operation-stack.js:180:12)
at OperationStack.run (/packages/vim-mode-plus/lib/operation-stack.js:96:14)
at /packages/vim-mode-plus/lib/vim-state.js:67:45)
at CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app/src/command-registry.js:388:36)
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
at WindowEventHandler.handleDocumentKeyEvent (/usr/share/atom/resources/app/src/window-event-handler.js:108:40)
-0:05.5.0 vim-mode-plus-user:insert-character (input.hidden-input)
-0:05.3.0 vim-mode-plus:set-input-char-space (input.hidden-input)
autocomplete-paths 2.12.1
autocomplete-python 1.10.5
document-outline 2.0.1
ex-mode 0.18.0
file-icons 2.1.15
git-plus 7.10.0
git-time-machine 1.5.9
go-config 1.2.4
go-get 2.1.1
go-hyperclick 1.1.2
Hydrogen 2.2.0
hyperclick 0.1.5
hyperclick-markdown 0.2.2
hyperlink-hyperclick 1.3.4
js-hyperclick 1.12.2
jupyter-notebook 0.0.10
kite 0.58.0
language-diff 0.7.0
language-latex 1.1.1
language-nxc 3.6.1
language-restructuredtext 1.1.0
language-weave 0.4.2
latextools 0.8.5
navigator-go 1.1.3
open-vim 0.2.3
path-hyperclick 0.3.0
pdf-view 0.61.0
preview-inline 1.5.1
python-indent 1.1.4
python-isort 0.0.7
python-mrigor 2.1.3
python-tools 0.6.9
rst-preview 1.3.1
rst-preview-pandoc 0.1.12
split-diff 1.5.1
table-editor 0.2.2
toggler 0.3.1
vim-mode-plus 1.24.4
The second issue has already been reported: https://github.com/t9md/atom-vim-mode-plus/issues/948. The exception is raised when pressing a character after the space.
updated wiki, try it again!
Now I get Failed to load ..../init.js
, Base is not defined
.
My complete init.js
is
"use babel"
class InsertCharacter extends Base.getClass("Operator") {
static commandPrefix = "vim-mode-plus-user"
target = "Empty"
readInputAfterSelect = true
mutateSelection(selection) {
const point = selection.getHeadBufferPosition()
this.editor.setTextInBufferRange([point, point], this.input.repeat(this.getCount()))
}
}
InsertCharacter.registerCommand()
Read whole doc at that page and also
Replace service.Base.getClass
to service.getClass
.
OK, I got it working. Thanks! I don't know what you mean with "Replace service.Base.getClass
to service.getClass
" but didn't need it.
I'm note sure about something. In init.js
can there be several calls to consumeService
? If yes, I'd write the code for InsertCharacter like this:
consumeService("vim-mode-plus", "provideVimModePlus", ({Base}) => {
class InsertCharacter extends Base.getClass("Operator") {
static commandPrefix = "vim-mode-plus-user"
target = "Empty"
readInputAfterSelect = true
mutateSelection(selection) {
const point = selection.getHeadBufferPosition()
this.editor.setTextInBufferRange([point, point], this.input.repeat(this.getCount()))
}
}
InsertCharacter.registerCommand()
})
If not, I would write the first and last lines (consumeService("vim-mode-plus", "provideVimModePlus", ({Base}) => {
and })
) with a comment in the wiki. At first, I didn't get that the code written in the wiki for InsertCharacter
has to be put inside the call to consumeService
.
Would it be possible to improve the already great documentation of this great plugin by adding a function
InsertCharacter
which, similar toInsertSpaces
, would insert the character specified after the command in normal mode? For example, if I bind it to` (space),
_` (space + underscore) would insert an underscore and stay in normal mode.Check list
vim-mode
not installed.