Can one edit a terminal buffer in Normal mode in NeoVim? - neovim

NeoVim's terminal mode is cool, but what I really would like is to
be able to switch to normal mode to edit terminal with normal mode commands, is it possible?
I realize that when in this terminal mode, all input is responsability of the terminal, so I see that a mode where input interaction travels between vim and the terminal shouldn't be simple, if it's doable at all, I'd just like to confirm.

It is possible.
However, the user needs to use the <C-\><C-n> key combo first,
which will exit back to normal mode. Once in "normal" mode the user can navigate, set marks, visually select text, use registers to yank and paste the output somewhere else, etc.
If the user comes back to insert mode (i or a, e.g.) the cursor will come be back to the terminal command line.
For general information about the terminal emulator: :h terminal-emulator
For specific information on terminal's input: :h terminal-emulator-input. This section includes a bunch tips that might be handy, such as how to map <C-\><C-n> to <esc>.

Related

Vim for Visual Studio - Ctrl+C Disabled Still Enters Normal Mode

I have set the following setting in VIM for Visual Studio
But when I press ctrl+c I still enter NORMAL mode.
I also tried to set my own vimrc
and add the ctrl-c remapping from there
# inside ~/.vimrc
map <C-c> "+y
But it still enters NORMAL mode, it works because atleast it does copy to the clipboard what i was trying to copy, but I thought it would get rid off the action of entering NORMAL mode.. I thought it would have rewritten that functionality for that shortcut instead it kind of doubles it.
I am getting used to it, but I wonder why that's the case.

Background mode for vim in windows

I've recently started moving away from my regular editor to vim and I use powershell as my default shell. I noticed in the normal mode that pressing ctrl z allows to quickly go back to the terminal ( although in a very different mode, regular shortcuts like ctrl L to clear screen etc. weren't working ). After reading through some posts I got to know that this shortcut is meant to put vim in backgroud mode in linux and fg brings it back to the foreground. Since this doesn't work in powershell is there an alternative way to get the same functionality?
PS: Is there also any alternative to reach powershell prompt from within vim?
Thanks!
The terminal command can be used to reach a powershell prompt from within Vim.
:term powershell
This will open powershell in a new terminal window.
There are various ways to invoke a terminal. For example, :tab term powershell will open the terminal in a new tab. :term ++curwin powershell will open the terminal in the current window. See :help :term for more details.
Here is some more relevant information from a prior post:
Using :term will place you in Terminal-Job mode, where you can use
the terminal as expected.
Within Terminal-Job mode, pressing Ctrl-W N or Ctrl-\ Ctrl-N switches the mode to Terminal-Normal, which
allows the cursor to be moved and commands to be ran similarly to
Vim's Normal mode. To switch back to Terminal-Job mode, press i.

Why doesn't emacs org mode work in -nw (--no-window-system) mode

I'm trying to give a shot to emacs org mode, so I created a file and started adding bullets and tasks, all fine.
I'd love to use emacs in -nw mode so it would blend into my workflow, but, when I open an org file in -nw mode, it read the bullets, but I can't use any of the org mode shortcuts and I get none of its benefits. Already double checked if I was indeed in org mode.
Am I doing something wrong?
It seems like your terminal is intercepting your keystrokes, and you should go into its settings to change that. If you're using Terminal for OSX, go to Preferences, and under the Profiles tab, select your profile and then the Keyboard tab. At the bottom there are two check boxes, and you just need to check "Use Option as Meta Key"

zsh auto-complete overflows emacs term-mode buffer

I'm running zsh inside multi-term.el (which, as I understand it, is almost identical to term-mode with some additional commands) in character mode.
Edit: emacs 24.5.1 in a terminal (-nw), zsh 5.0.2, https://github.com/ayrtonmassey/config for my full config
When I hit TAB to invoke zsh's auto-complete, if the prompt is at the bottom of the screen the auto-complete options are hidden. This only happens on specific auto-completions: for example, pressing TAB after cd does not show the list of possible files/directories, but auto-completing names of executable files (e.g. typing b and hitting TAB) will show all the possible executables.
The currently selected auto-complete value is shown beside the prompt in all cases.
I assume this is something to do with it not scrolling down to show the output, but I can't find any more information.
I had the same problem, and after fiddling with the Customize group for term, it seems that setting the variable term-scroll-show-maximum-output to a non-nil value solves this problem (at least for ansi-term).

How can I configure emacs to switch to a particular buffer when I click the mouse in it?

I'm using iTerm2 on my mac to ssh into a Linux box and run emacs in the terminal. On a big monitor, I like to split the window to see multiple buffers side-by-side. I'd like to be able to switch to a particular buffer by clicking the mouse in it (rather than doing C-x o).
What seems to be happening is that if I click the mouse anywhere outside the currently active buffer e.g. in the next buffer, on the mode line etc., the click is being interpreted as which is bound to (tmm-menubar-mouse EVENT).
I have disabled the menubar by doing the following in my .emacs_d/init.el:
(menu-bar-mode -1)
This seems to disable the visible display of the menu bar at the top of the window, but the mouse click behavior I described is still happening.
I think what I need is to have the click interpreted as something other than and then bind that to some function that detects which buffer the click happened in and switch to it. But, I don't know how to do that and the searching I've done hasn't yielded any clear answer. Can anyone help?
Alternatively, I looked into using windmove to enable switching between buffers with SHIFT and the arrow keys. I did (windmove-default-keybindings) but emacs then seems to respond to SHIFT left-arrow by inserting "2C" into the buffer and SHIFT-right-arrow by inserting "2D". If anyone has any tips on making this work too, I'd love to hear them.
Thanks
I ran into this problem a while ago, where clicking on column > 95 was interpreted as <menu-bar> <mouse-1>, which invokes tmm-menubar-mouse. It turned out to be a bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6594
There hasn't been a formal release since this bug was fixed, but you can get the patch here:
http://bzr.savannah.gnu.org/lh/emacs/emacs-23/revision/100618
If I recall correctly, you should be able to just drop the modified file into your existing emacs installation and byte-compile it (assuming you're running the 23.3.1, the latest release).