In PatentStorm, I used Ctrl+W — Ctrl+Shift+W to fold / unfold code.
I migrated to Atom — is this possible to mimic?
Custom Keymap
Add this to your keymaps:
'atom-text-editor':
'ctrl-w': 'editor:fold-current-row'
'ctrl-shift-w': 'editor:unfold-current-row'
Atom Keymaps In-Depth
Atom Defaults (Windows)
You can fold blocks of code by clicking the arrows that appear when
you hover your mouse cursor over the gutter. You can also fold and
unfold from the keyboard with the Alt+Ctrl+[ and Alt+Ctrl+] keybindings.
Atom Code Folding
Single Key Fold-Toggling
If you'd like to use a key binding to fold-toggle, create a custom command:
atom.commands.add 'atom-text-editor',
'editor:toggle-current-row-folding': (event) ->
editor = #getModel()
bufferRow = editor.bufferPositionForScreenPosition(editor.getCursorScreenPosition()).row
if editor.isFoldedAtBufferRow(bufferRow)
editor.unfoldBufferRow(bufferRow)
else
editor.foldBufferRow(bufferRow)
Here you would use 'editor:toggle-current-row-folding' as your command.
From abe + kschaper # How to toggle current fold in editor view?
Related
I have searched for the string "as" a few hours before in Qt Creator.
However it seems to be still active and whenever I type "as" again it is highlighted automatically.
And I can't get rid of it.
It looks like this:
Do you know what could be the problem and how to remove the yellow highlight?
According to your comment, you are using FakeVim so you can set whether or not search results are highligthed in Qt Creator ( Tools > Options > FakeVim). And if you want to clear the highlighted results, just type :nohlsearch in FakeVim.
If you are using FakeVim you can set up a user command in Tools -> Options -> FakeVim -> User Command Mapping. E.g., User command #1 = ":noh". Then you can use 'Alt+V 1' to get rid of the yellow highlight.
I use Atom on Ubuntu 17.10 with wayland window manager.
I can create multiple cursors with CTRL+Mousclick or with CTRL+d to select the next same string.
But how can I for example mark some lines and create a cursor at the start of each line?
Also would be great to use search and find-all to select lots of results in a text to create a cursor at all these results.
I used this workaround at the moment by selecting the line-break and use CTRL+d to select the next linebreaks too with extra cursors, then go one left and Pos1 to have the cursors at the start of each line.
I wanted to select a string that repeats about 200 times in a dataset of 3000 text-blocks in a bunch of output and then I wanted to expand the selection to each of those blocks. That would have been really easy with multiple cursors. I solved this another way now, but for the next time I would like to see a complete instruction manual about how to create multiple cursors in the standard atom setting. I couldn't find this. Search-engines give me lots of plugins and solutions in different multicursor plugins.
I found the manual that explains it like in sublime (ctrl alt up and down):
Alt+Shift+Up and Down
see: https://flight-manual.atom.io/using-atom/sections/editing-and-deleting-text/#multiple-cursors-and-selections
What is missing in the manual is also a useful option:
use "find all" with the search tool in Atom (CTRL+F)
press Alt + Enter to create cursors at all the found locations.
see: https://discuss.atom.io/t/how-do-i-create-multiple-cursors-from-search-result/53231/5
I wanted to make it easy so I could just use alt+⬇️ or alt+⬆️ to have multiple cursors. This was my solution and I think its the easiest:
# From Atom -> Keymap add the following lines:
'.editor':
'alt-up': 'editor:add-selection-above'
'alt-down': 'editor:add-selection-below'
I have installed vim-mode-plus package and added the following keymap bindings in the keymap.cson file.
'atom-text-editor.vim-mode-plus.normal-mode':
'ctrl-j': 'focus-pane-or-panel:focus-below'
'ctrl-k': 'focus-pane-or-panel:focus-above'
'ctrl-h': 'focus-pane-or-panel:focus-on-left'
however I am not able to switch between the panes ( I am on Windows)
I am able to switch if I use a built-in keybinding as below:
ctrl-w ctrl-j window:focus-pane-below Vim Mode Plus atom-text-editor.vim-mode-plus:not(.insert-mode)
Above is copied from the Keybindings search results in atom
I don't think you are using the right command names. If you open the Command Palette (CtrlShiftP), you can search "focus" and find the various commands available for what you're trying to do.
Window: Focus Pane Above
Window: Focus Pane Below
Window: Focus Pane On Left
Window: Focus Pane On Right
To turn these into keybind command names, apply this formula:
Lowercase everything
Remove the space after :
Replace remaining spaces with hyphens
This gives the keybind command names:
window:focus-pane-above
window:focus-pane-below
window:focus-pane-on-left
window:focus-pane-on-right
Also notice the working example you point to uses a different selector than you are using. It uses atom-text-editor.vim-mode-plus:not(.insert-mode) rather than atom-text-editor.vim-mode-plus.normal-mode. That may be a better option, so your key bindings would work in modes other than normal mode (such as visual select mode).
I think what you need is:
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'ctrl-j': 'window:focus-pane-below'
'ctrl-k': 'window:focus-pane-above'
'ctrl-h': 'window:focus-pane-on-left'
And I'm not sure if you also wanted CtrlL to work, e.g.
'ctrl-l': 'window:focus-pane-on-right'
I'm a new Atom user and I want to override the Atom command palette (shift-ctrl-p) scrolling key bindings to something more vi friendly like
ctrl-n and ctrl-p instead of the annoying arrow keys (which force me to take my hands off the home row).
Just to be clear, I don't want to change the key binding that brings up the command palette, but the key bindings you use to scroll through the list once it's up:
I can only find a binding to override the command palette toggle:
As you can see in the following config file, I was able to override the autocomplete scrolling, and I hope to do the same with the command palette. I've tried 'command-palette:up' ,'command-palette:down' and 'command-palette:move-up' etc. to no avail.
Here's is my keymap.cson.
# Atom Flight Manual:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
#vt add
'body atom-text-editor.autocomplete-active':
'ctrl-p': 'autocomplete-plus:move-up'
'ctrl-n': 'autocomplete-plus:move-down'
'alt-p': 'autocomplete-plus:page-up'
'alt-n': 'autocomplete-plus:page-down'
'home': 'autocomplete-plus:move-to-top'
'end': 'autocomplete-plus:move-to-bottom'
# vim-plus ex mode 2016-04-18
'atom-text-editor.vim-mode-plus.normal-mode':
':': 'vim-mode-plus-ex-mode:open'
'!': 'vim-mode-plus-ex-mode:toggle-setting'
# add cmd palette key bindings --> These do not work.
'body .native-key-bindings':
'ctrl-p': 'command-palette:up'
'ctrl-n': 'command-palette:down'
#vt end
I've been really impressed with the key binding support in Atom thus far. I'd be really surprised if it couldn't handle this but, alas, I think this might be the case.
Does anyone know of a way to do this?
Atom 1.7.2, linux
I was able to get single line scroll to work, but not page scroll to work with the following in my keymap.cson:
'atom-workspace':
# these work
'ctrl-p' : 'core:move-up'
'ctrl-n' : 'core:move-down'
# these don't work
'alt-p' : 'core:page-up'
'alt-n' : 'core:page-down'
It would be nice to have page scroll as well, but I should be able to narrow down the list down by typing in text, so I don't foresee needing page-up, page-down all that often.
Now I'm happy.
To target keybindings for just the command palette, you can find an appropriate selector by looking in the command-palette repo keymaps: https://github.com/atom/command-palette/blob/v0.43.5/keymaps/command-palette.cson
This suggests the use of the .command-palette selector, which seems more appropriate then atom-workspace.
'.command-palette':
'ctrl-n': 'core:move-down'
'ctrl-p': 'core:move-up'
I was not able to find a mapping to scroll a page at a time within the command palette, though I'm sure someone else can figure it out. The keyboard page up/down keys have no effect so mapping to core:page-down etc. is not going to work.
I am trying to create a key binding for "Evaluate buffer till here" in Emacs & ESS, which is situated in ESS => ESS Eval menu. Most of the commands in that menu are listed in help files (http://ess.r-project.org/Manual/ess.html, and in Emacs options), but this particular one is not. If I place following code in .emacs file:
(eval-after-load "ess-mode" '(define-key ess-mode-map (kbd "C-.") 'ess-eval-buffer-till-here))
I get a following message when trying to use the binding: Symbol´s function definition is void: ess-eval-buffer-till-here. Obviously I am calling for wrong name. What is the right name for this command and how can I see all of the commands for ESS?
So it's a menu item? Type C-hk and then select that item.
(Menus are implemented as keymaps, so this is just the normal describe-key functionality.)
You can also see the non-interactive call form of the last command with C-xESCESC or C-xM-:. It's easy to figure out the command name once you have that. (thanks event_jr)
For listing all commands, most modes will list all their key bindings in their docstring, so you can use C-hm to describe the modes in use in the buffer.
As there may be commands without bindings, you could also use M-x apropos-command to list them all (most likely specifying ^ess as a pattern, if it uses that as a consistent name space).