Vim keymaps in atom - atom-editor

As far as I understand, there is no way to run .vimrc from atom in vim-mode-plus, but I can still use atoms way of binding keys using keymap.cson. How can I move the keys H-J-K-L one key right (J-K-L-Ø, since I have a Norwegian keyboard) using keymap.cson?

You can add maps like this in keymap.cson:
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'J': 'vim-mode-plus:move-left'
'K': 'vim-mode-plus:move-down'
'L': 'vim-mode-plus:move-up'
'Ø': 'vim-mode-plus:move-right'

Related

create multicursor in Atom

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'

Keybindings with ZSH

Can anyone tell me how to move back a word in ZSH? Ctrl+b will move back a character but not an entire word.
For instance a log command like this:
knife zero bootstrap mbigglesworth#10.10.1.108 --sudo-preserve-home --ssh-user mbigglesworth --sudo --policy-name linux_mint_wkstn -N linuxmint-vm -VV
...is painful to get to the middle of!
ESCAPE+b or ESCAPE+f to move back one word or forward one word respectively
EDIT
The mentioned above are the defaults(as far as I'm concerned)
#TyMac mentions that the defaults are uppercase in his system though (ESCAPE-B, ESCAPE-F)
You may perfectly set them manually by inserting the following lines in your zshrc
bindkey "^[b" backward-word
bindkey "^[f" forward-word
in case you don't like the defaults you may set it to some different key combo using this same syntax (I would suggest that it's preferable to use the defaults though but that's just personal opinion)
Ctrl+Left or Ctrl+Right to move back and forward one word.
It does, however, depend heavily on your configuration. Read more here.
A list of other handy default keybindings is here

Bash via Platformio on Atom: arrow keys not functioning

I'm using the Windows Subsystem for Linux Bash in Atom via Platformio - and none of the arrow keys work.
There was an ongoing bug in WSL Bash with the arrow keys that should've been fixed, so I opened system32\bash.exe to test, and indeed the arrow keys work there; the problem happens only in Atom.
Does anyone know of a workaround/solution?
Thanks!
I've had this problem myself but I haven't found a full solution. It looks like there's a bug lurking upstream.
Until it's patched, here's a list of alternative commands courtesy of CherryDT in this thread:
Ctrl+P: Previous command (like up arrow)
Ctrl+N: Next command (like down arrow)
Ctrl+B: One character backwards (like left arrow)
Ctrl+F: One character forwards (like right arrow)
Ctrl+A: Start of line (like home key)
Ctrl+E: End of line (like end key)
Ctrl+D: Delete character (like delete key)

Move cursor up/down one line in Atom

I'm using Atom with soft wrap turned on. In most simple editors such as gedit, Ctrl-Down would be used to skip ahead to the true next line, ignoring any wrapped lines below (same as j and k in Vim).
However in Atom this shortcut produces the result of moving the line itself around, which is less useful to me. I'd like to remap Ctrl-Up and Ctrl-Down to move the cursor up or down to the next true line, as described above.
I'm familiar with editing my keymap file, but I simply can't find any command that would be the equivalent of moving ahead one full line.
You could write a custom command in your init.coffee like this:
atom.workspaceView.command 'custom:move-next-buffer-line', ->
editor = atom.workspace.getActiveEditor()
editor.moveCursorToEndOfLine()
editor.moveCursorRight()
And then just reverse it for moving to the previous buffer line. You can then map the custom command in your keymap, which you said you're familiar with.
If you're using the vim-mode-plus package, then just modify your keymap.cson file by adding
# except insert
# -------------------------
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
# Motions
# -------------------------
'k': 'vim-mode-plus:move-up-screen'
'j': 'vim-mode-plus:move-down-screen'
See for details https://github.com/t9md/atom-vim-mode-plus/blob/master/keymaps/vim-mode-plus.cson

Why do <C-PageUp> and <C-PageDown> not work in vim?

I have Vim 7.2 installed on Windows. In GVim, the <C-PageUp> and <C-PageDown> work for navigation between tabs by default. However, it doesn't work for Vim.
I have even added the below lines in _vimrc, but it still does not work.
map <C-PageUp> :tabp<CR>
map <C-PageDown> :tabn<CR>
But, map and works.
map <C-left> :tabp<CR>
map <C-right> :tabn<CR>
Does anybody have a clue why?
The problem you describe is generally caused by vim's terminal settings not knowing the correct character sequence for a given key (on a console, all keystrokes are turned into a sequence of characters). It can also be caused by your console not sending a distinct character sequence for the key you're trying to press.
If it's the former problem, doing something like this can work around it:
:map <CTRL-V><CTRL-PAGEUP> :tabp<CR>
Where <CTRL-V> and <CTRL-PAGEUP> are literally those keys, not "less than, C, T, R, ... etc.".
If it's the latter problem then you need to either adjust the settings of your terminal program or get a different terminal program. (I'm not sure which of these options actually exist on Windows.)
This may seem obvious to many, but konsole users should be aware that some versions bind ctrl-pageup / ctrl-pagedown as secondary bindings to it's own tabbed window feature, (which may not be obvious if you don't use that feature).
Simply clearing them from the 'Configure Shortcuts' menu got them working in vim correctly for me. I guess other terminals may have similar features enabeld by default.
I'm adding this answer, taking details from vi & Vim, to integrate those that are already been given/accepted with some more details that sound very important to me.
The alredy proposed answers
It is true what the other answer says:
map <C-PageUp> :echo "hello"<CR> won't work because Vim doesn't know what escape sequence corresponds to the keycode <C-PageUp>;
one solution is to type the escape sequence explicitly: map ^[[5^ :echo "hello"<CR>, where the escape sequence ^[[5^ (which is in general different from terminal to terminal) can be obtained by Ctrl+VCtrl+PageUp.
One additional important detail
On the other hand the best solution for me is the following
set <F13>=^[[5^
map <F13> :echo "hello"<CR>
which makes use of one of additional function key codes (you can use up to <F37>). Likewise, you could have a bunch of set keycode=escapesequence all together in a single place in your .vimrc (or in another dedicated file that you source from your .vimrc, why not?).

Resources