Go to end of parenthesis / parenthesis / quote in atom editor using TAB

In the atom editor, when I type console.log( for example, it becomes console.log() and the cursor stays between the two brackets. So I have to use the END button or the right arrow key to jump from there. Is there a way to use TAB instead (to pop out of the end brace / parenthesis / quote)?

+6
source share
2 answers

If you just keep typing, then closing ) will be "swallowed" by matching Atom brackets, so you don't need to press End or β†’ .

However, there are situations where matching Atom brackets does not absorb keystrokes, and you cannot just type. For example, when you enter the following code, after clicking ; you may need to move the cursor behind the closing curly bracket (which Atom automatically inserted):

 if (someCondition) { doSomething(); } 

In such situations, you can use a custom command and a custom key combination to move the cursor forward. Here's how ...


Go to the file menu and select "Open Your Init Script", then paste the following code into the file. This defines a command that can move the cursor forward by jumping over a single bracket, bracket or quotation mark.

 SymbolRegex = /\s*[(){}<>[\]/'"]/ atom.commands.add 'atom-text-editor', 'custom:jump-over-symbol': (event) -> editor = atom.workspace.getActiveTextEditor() cursorMoved = false for cursor in editor.getCursors() range = cursor.getCurrentWordBufferRange(wordRegex: SymbolRegex) unless range.isEmpty() cursor.setBufferPosition(range.end) cursorMoved = true event.abortKeyBinding() unless cursorMoved 

You need to close and reopen Atom to reload the init script.

Then go to the file menu, select "Open Your Map" and enter the key for the new command. You could use the TAB key, but that would contradict the default Atom keywords for fragments, so here I used Alt + ) :

 'atom-text-editor:not([mini])': 'alt-)': 'custom:jump-over-symbol' 

Another option is to simply disable the automatic installation of Atom closing brackets. I think you can do this by going to Settings & rarr; Packages β†’ bracket-matcher β†’ Settings and clearing the option β€œAuto-complete brackets”.

+14
source

I also wanted this in Atom, so I went ahead and made a package for it. https://atom.io/packages/tab-through

The added value over the crumbletown solution is that you can change the key binding (I personally prefer the tab, and therefore the package name) and the characters you want with the package settings, as well as the need to make changes to the init script.

+3
source

Source: https://habr.com/ru/post/987331/


All Articles