Setting a fresh keybinding in Atom on macOS

Recently, I decided to switch over to using Atom on my Macbook and I wanted to set up a keybinding where alt-up arrow would act as page up and alt-down arrow for page down. Despite my efforts, I have not been successful in getting this to work.

I'm puzzled by the disparity between

'atom-text-editor':

and

'atom-text-editor:not([mini])':

and which one is appropriate for my needs. Additionally, there's a package called Emmet that I've installed which also uses alt-up and it keeps overriding my attempts at creating the keybinding. I was under the impression that the keymap.cson file should take precedence over any third-party packages.

Answer №1

Discovering the Mini Scope

The concept of the mini scope is geared towards handling single-line inputs. Instances like the "Find" or "Find in Project" panels utilize mini editors to receive input. By using the selector not([mini]), you can exclude these mini editors, ensuring that your binding only affects code editor windows/panes.

In practical terms for this scenario, it may not have a substantial impact since mini editors typically do not respond to actions like page-up or page-down. However, adhering to proper scoping practices for key bindings is considered a good habit rather than applying them globally.

Understanding Selectors

A suitable selector you already possess (atom-text-editor:not([mini])). Your question touched on additional selectors such as atom-workspace and ::shadow. While I lack a thorough explanation of ::shadow, you may delve further into it including resources like this link.

atom-text-editor is scoped to text editor panes while atom-workspace has a broader scope encompassing the entire window, possibly including elements like the tree view, tabs, and status bars.

Anatomy of a Key Binding

To create a key binding, there are three essential components:

  1. A selector defining where the binding applies. This was addressed in your query: atom-text-editor:not([mini])
  2. The specific key bindings to use, documented in Atom's documentation. For this case, alt-up and alt-down are required.
  3. An Atom command corresponding to each key binding.

Navigating Atom Commands

Utilizing the Command Palette

You can access all Atom commands through the Command Palette (CmdShiftP). Upon searching for terms like "page", relevant commands like "Core: Page Up" and "Core: Page Down" will appear. To convert these into usable commands, follow these steps:

  1. Remove the space after the colon

  2. Replace spaces with hyphens

  3. Lowercase all characters

This transformation results in core:page-up and core:page-down.

Using the Key Binding Resolver

If you wish to remap a command linked to one key to another key, you can leverage Atom's Key Binding Resolver. Pressing Cmd. will activate the resolver, indicating which command each keypress corresponds to. In this case, pressing PageUp or PageDown reveals the associated core:page-up and core:page-down commands.

Implementing Your Keymap

Access Atom's preferences to click "Open Config Folder," opening a new editor window loaded with the config folder contents. Within the keymap.cson file, include your new keymap like so:

'atom-text-editor:not([mini])':
    'alt-up': 'core:page-up'
    'alt-down': 'core:page-down'

Save the file, and your updated keymap should take effect immediately.

Answer №2

If you want to create new keybindings, simply navigate to your ~/.atom/config.cson file and add your custom keybinding using the syntax below:

'atom-text-editor':
  'ctrl-alt-s': 'my-custom-command:execute'

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generate a collection of LatLng coordinates to represent a worldwide grid

I'm in search of a quick and easy solution, like a simple library or similar tool, that would allow me to call a function like createGlobalGrid(1000) and automatically generate a list of points on a geospatial surface, ensuring that each point is no m ...

invoking a function through prototype

<script> var Nancy = function(){ this.name = 'nancy' } Nancy.prototype.getNancy = function(){ alert(this.name); } Nancy.prototype.getNancy(); function Bob(){ ...

When making an Ajax request, the response is received successfully, however, the success, complete, and error

I am attempting to retrieve SQL results from a database using an AJAX call and display them on another PHP page. Here is my AJAX call code: function newfunc(){ start += 10; var params = parseURLParams(document.URL); var datastring = "nextStart="+start+"&a ...

Is it possible to insert a second hyperlink into a JavaScript-occupied anchor?

Check out my reference page at: To change the content in a 'containerarea' div, I am utilizing Dynamic Drive's "Dynamic Ajax" script. Below is an example of the anchor code used: <a href="javascript:ajaxpage('videos-maintenance/app ...

The mesh's position has become invalid due to the dynamic change in vertices' positions

When attempting to create a mesh using PlaneGeometry, I encountered an issue where after dynamically changing the geometry's vertices, the mesh's position and rotation were no longer correct. Is there a way to update these properties properly to ...

Manipulating HTTP responses and variables in Angular 6

I created a custom application using the MEAN stack that allows users to sign up and log in. To enhance security, I want users to reconfirm their identity by entering their password or a PIN if they return to the application after some time. To achieve th ...

Fetching Dependencies with NPM from the package.json file

I am feeling a bit puzzled. While working on my laptop, dependencies were automatically added to my package.json file as I installed them for my project. This is how it appears: "main": "webpack.config.js", "dependencies": { "immutable": "^3.7.6", ...

JavaScript | Calculating total and separate scores by moving one div onto another div

I have a fun project in progress involving HTML and Javascript. It's a virtual zoo where you can drag and drop different animals into their designated cages. As you move the animals, the total count of animals in the zoo updates automatically with the ...

Angular error ReferenceError: $Value is not defined in this context

As a newcomer to AngularJS, I am facing an issue while passing a list from the HTML file to the backend for processing. The error message ReferenceError: $Value is not defined keeps popping up. Within my controller file, I have a function named test. The ...

What are the differences in how a link tag responds on mobile devices?

I have a question regarding opening a pdf in an iframe on the current page. Is there a way to handle this differently for mobile/tablet users? For example, clicking the link could open it in another tab for better readability instead of within the iframe ...

What strategies can be used to stop elements from reverting to their original state?

Hey there, I'm currently experimenting with animation and trying to create a cool two-step effect: 1. elements falling down and 2. pulsating on click. However, I've run into an issue where after the clicking action, the elements return to their o ...

Any suggestions on how to retrieve data into Tabulator using the POST method?

I am currently utilizing Tabulator 4.6 and have an API that supports the POST method. My goal is to retrieve data from Tabulator through a POST request instead of a GET request. Within my org.js file, I have the following configuration: var ajaxConfig = { ...

Getting the URL path within getStaticPaths in Next.js

Is there a way to retrieve the last number from the current URL pathnames in getStaticPaths? http://localhost:3000/category/food/2 -> 2, http://localhost:3000/category/food/3 -> 3, ... I have attempted: export const getStaticPaths: GetStaticPaths = ...

Is it possible to bind computed values in Ember using .properties(...) with ember-model?

I'm attempting to utilize the .property('key') syntax in order to update a computed value within my model. The structure of my model is as follows: App.Camera = Em.Model.extend({ id: attr(), uid: attr(), name: attr(), type: ...

Breaking Down the Process of Exporting a Next.js Static Website into Manageable Parts

I am facing memory issues while building my website using Next.js's Static HTML Export. The site has a large number of static pages, approximately 10 million. Is it feasible to export these pages in batches, like exporting 100k pages in each build ite ...

How can you establish an environmental variable in node.js and subsequently utilize it in the terminal?

Is there a way to dynamically set an environmental variable within a Node.js file execution? I am looking for something like this: process.env['VARIABLE'] = 'value'; Currently, I am running the JS file in terminal using a module whe ...

Problem with selecting items in Kendo UI Menu

Problem: The select event is not triggering when clicking on the image in the kendo menu item. My troubleshooting steps: Review the sample code provided below <!DOCTYPE html> <html> <head> <base href="http://demos.telerik.com/ken ...

Protractor unexpectedly giving back a promise instead of the expected attribute value

I'm facing a challenge where I am attempting to extract the value of an HTML attribute and store it in a variable named url_extension. However, instead of getting the desired value, I keep receiving a Promise object. Below is my code snippet: (Please ...

Angular JS allows you to easily remove the # symbol from a URL, improving the

I am encountering a problem with the "#" symbol in my angular js website's URL. I need to remove the # from the URL but the method provided isn't working and the site is not displaying properly. Can someone advise me on how to successfully remove ...

What is the method for verifying the Swift version in Playground?

While testing my code in Xcode 8.2 playground using a Swift tutorial, I encountered the following sample code: One-Sided Ranges for name in names[2...] { print(name) } However, now my playground is showing an error. As a result, I suspect that my c ...