Keymap - action depending on what's under cursor


I’m wondering if it’s possible to differentiate keymap actions based on what’s under cursor.

Example: if there’s a number under cursor, I run Emmet’s “Increment by one” action. Otherwise, I run the editor’s “Move line up” action.

I tried putting something like this in my keymap file:

'atom-workspace atom-text-editor:not([mini])':
  'ctrl-up': 'editor:move-line-up'
  'ctrl-down': 'editor:move-line-down'
'atom-workspace atom-text-editor:not([mini]) .numeric':
  'ctrl-up': 'emmet:increment-number-by-1'
  'ctrl-down': 'emmet:decrement-number-by-1'

But that didn’t work. Not saying it should, I just thought it might. Is there a way to do it without getting into plugin development?


You can do it without developing a package, yes. But you can’t do it without writing some code, no. See this recent topic for an example of something similar:


Thanks, I’ll check it out. If I come up with a solution, I’ll post it here.