Adding your own commands
Hi, I've been attempting to implement my own command, namely :t
which basically does :copy but without the range, and you can do +1 or -1, which makes up for a quick copy+paste for line-duplication. e; been using these functions; https://atom.io/docs/api/v0.101.0/api/classes/Editor.html (atom.workspace.getActiveTextEditor().blah())How does one go about this? It does not seem to work reliable with the README example for 'Extend'.
e; while we're at it, it would be kinda amazing if these was added by default :[range]co[py] {address}, :[range]m[ove] {address} - they don't seem too difficult to create seeing the Editor docu in Atom's API.
If you are happy enough directly editing the source (I did, as a quicker hack than working with extending), you can edit ex.coffee in /atom/packages/ex-mode/lib/ and add additional commands into the Ex class. I did this as a quick way of making :W an alias for :w
w: (args...) =>
@write(args...)
W: (args...) =>
@write(args...)
Which isn't the most reliable, but it does for now.
Also:
# in Atom's init.coffee
atom.packages.onDidActivatePackage (pack) ->
if pack.name == 'ex-mode'
Ex = pack.mainModule.provideEx()
Ex.registerCommand 'z', (args...) -> @console.log(args...)
I'm not particularly familiar with either javascript or coffeescript as they are not my production languages, so not quite sure how to access methods of the Ex class, as my desired command is something along the lines of Ex.registerCommand 'W', (args...) -> Ex.write(args...)