Disable Return after i in vim - neovim

I have a bad habit of pressing the Return immediately after pressing the i key, when the o key would save keystrokes. I would like to disable the i-Return combination to help me break this habit.
I tried to add
imap <Return> <NOP>
to my ~/.config/nvim/init.vim, but this disables pressing it in insert mode entirely. Is there a way to disable it only upon immediately entering insert mode?

How about this combo:
nnoremap <silent> i<CR> :echoerr "Use o instead"<CR>
This will issue the error only if you press both i and <Enter> within 'timeoutline' (default one second).

Related

How to stop NeoVim from sending ^S character while I press Ctrl+S in Insert Mode?

I wanted to remap <C-s> to save a file. It works fine in normal mode. But when I'm in Insert Mode and I press Ctrl+S, it just send the character ^S (as a single character).
I'm using Windows 10 and Powershell to open NeoVim. Is there a way that I can map Ctrl+S to save the file in my current situation? Also should I stick to Powershell or should I switch to another terminal?
I would try remapping it to something like
leave insert mode
save
return to insert mode, after the cursor
inoremap <C-s> <Esc>:w<cr>a

How do you use <TAB> to cycle through completion suggestions with ALE?

When using Ale, I'd like to use the Tab key to cycle through completion suggestions. By default, the arrow keys do it. What are the various configuration options for cycling through the suggestions as well as selecting the correct completion?
Could do something like this:
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" : "\<TAB>"
Essentially, when you hit tab in insert mode, check whether the popup is visible, and if it is then send Ctrl-n (to go to the next match), otherwise send a tab.

Emacs company mode inserts completion on space key pressed

Typing text in Emacs with company-mode turned on. When I stop at the end of a word company-mode shows available completions. Because the word is already written, it does not need to be auto-completed and I want to type another word, I press space key. company-mode inserts first suggestion instead of canceling auto-completion. Is this normal? How can I make company-mode to cancel auto-completion when I insert space character?
Example:
This file is
Cursor right after "is" and company-mode shows some auto-completion suggestions. After I press space key I get:
This file isearch-adjusted
("isearch-adjusted" was the first suggestion in the tooltip of company)
See the description of company-auto-complete, and set it to nil to disable this behavior.
It's nil by default, though, so it shouldn't have caught you unawares. Are you using someone else's Emacs config?

Turn off selection mode after I-searching for the word that was found

After searching for a word using an I-search, the selection mode remains enabled and pressing the escape button just once does not turn it off.
Is it possible to search for a word (forwards / backwards) and quickly go on about my business without pressing a bunch of keys to exit out of the select mode?
Also, the selection mode looks useful -- is there any way to turn it on / off without first performing a search?
Thanks.
You probably have transient-mark-mode enabled, which is now the default Emacs behavior. (It was not enabled by default in older versions of Emacs). If you're not familiar with it you may want to read about it in the Emacs manual.
You can set the mark (begin selection) using Control-space (C-SPC, the default key binding for set-mark-command). Then you can use other navigation keys to extend the selected region before you operate on it. For example: C-SPC to set the mark, M-f M-f to extend the selection forward two words, C-w to delete the selected region.
If you set the mark before beginning an incremental search, the search acts as a navigation command and extends the selected region. Exiting the search will leave the entire region selected from the place where you set the mark to the place where you exited the search. Note that this is not the default behavior for isearch-forward however.
just press ENTER to end the search.
if you mean that the selection area is displayed, you can unmark it with Ctrl-Space.
but I am not sure this answers your question.
--dmg

Right ALT key not working as meta key in emacs

I have launched emacs (emacs -Q) in the console(Ctrl+Alt+F1). The "left Alt key" is
working whereas the "right Alt key" is not working. How to fix the problem. I am running emacs on archlinux
This behavior is controlled by the keyboard layout you are using. In the layout that you are using, the left alt is Meta, whereas the right alt is Alt-graphic which allows you to enter accentuated character. Change your keyboard layout to one not using the right alt as Alt-graphic
The solution is described here:
http://www.joshstaiger.org/archives/2005/04/fixing_the_righ.html
It needs some modifications though (see item 3.2 below).
Otherwise one would not be able to type anything in current console after the first press of [Right Alt].
If this happened to you, switch to other console (e.g. [Ctrl+Alt+F2]) and restore old keymap.
Here is the brief description of the modified solution:
Save current keymap to file:
dumpkeys >> mykmap
and make a backup of it:
cp mykmap oldkmap
Capture [Right Alt] keycode using showkey command. Let's assume it is 100.
Edit mykmap:
Find the corresponding line:
keycode 100 = AltGr
and change it to:
keycode 100 = Alt
If the next line (or one of the next lines) is:
alt keycode 100 = Compose
remove it.
Load new keymap:
loadkeys mykmap
Make the changes permanent (e.g. add the last command to ~/.bashrc).