Bind Ctrl-C in fish vi-mode to switch from insert mode to normal mode - fish

I would like to use Ctrl-C to go from insert to normal mode in fish vi-mode, as I do in vim. I'm fairly new to fish and couldn't get it to work, though I tried this in my config.fish:
bind -M insert \cc set fish_bind_mode 'default'
Strangely I am able to go from Visual to Normal mode with Ctrl-C.
Thanks

Binding [ctrl-C] would require that you also change the stty intr character. Something that is currently impossible from within fish due to how it handles tty modes. You could, however, change it before starting fish. That would then free the character to be bound as you wish. Though you'll need to do this to get the correct behavior:
bind -M insert \cc 'set fish_bind_mode default; commandline -f repaint'

Related

Similar Neovim mappings--one works, one does not work

Context
Creating remappings to exit TERMINAL mode and enter NORMAL mode within neovim (ie. <C-\><C-N>).
I'm getting no-op behavior (ie. terminal stays in TERMINAL mode and simply ouputs , -- mapleader) when creating a new mapping as follows (in init.lua):
keymap.set("t", "<leader><Esc>", "<C-\\><C-N>")
Shell is zsh and I've set bindkey -v in .zshrc. Terminal application is iterm2.
When I set the following mapping:
keymap.set("t", "<leader>nn", "<C-\\><C-N>")
The expected behavior happens (ie. terminal exits TERMINAL mode and enter NORMAL mode).
Not sure how/where the first mapping is getting interrupted to not exit TERMINAL mode.
Question
Why is the first mentioned mapping not working, which the second mentioned mapping is working?
Effort
Looked on other posts and they all indicate there should be no problem with the first mapping.

Run (neo)vim motions, both insert and normal mode headlessly through commands with stdin

I'm creating a vim game where the purpose is to use vim motions to alter a buffer. It's a web game so I would have to emulate the inputs being sent from the client to the server, one challenge is going from insert mode to normal mode somehow. I'm running neovim behind an API, and this is how I'm able to run things from the app/frontend:
$ echo "foo" | nvim --headless --clean +"norm l" +"%print" +"echo getpos('.')" +q! -
I'm echoing "foo" into vim and using the norm command to alter it.
Inside the +"norm l" command I'm able to input vim motions, in this case moving the cursor right one character.
It works well, however, it can only handle things through normal mode. If I were to input ifoo<Esc>, which for me would translate to i, foo and then hitting the escape key, <Esc> is treated as an literal. Same thing with <C-c> and jj.
$ echo "foo" | nvim --headless --clean +"norm ifoo<Esc>" +"%print" +"echo getpos('.')" +q! -
foo<Esc>foo
[0, 1, 8, 0]
Is there a way to do this that I'm not seeing?

Emacsclient crashes when evaluating window functions

To not bore anyone here with specifics, whenever I evaluate an expression similar to this one:
emacsclient -t -e '(set-buffer *scratch*)'
the client will flash up on the terminal and crash.
This seems to be happening with all window-changing functions. Is the client not supposed to work like that? Running this in a normal emacs session does not cause this problem.
You're also using -t, but I'm not exactly sure why.
Is your emacs running in another tty session?
Or is your emacs running in windowing mode (e.g. on X Windows)?
If I have emacs running in windowing mode and I run the following command from another xterm window, then everything works exactly as I would expect it to:
emacsclient -c -e '(set-buffer "*scratch*")
Note in particular the -c option, and the fact that the buffer name is a string and so must be enclosed in double-quotes.

How can I make emacsclient just open a window for an existing emacs daemon without opening a new file

I use an emacs daemon to preserve my emacs session even if I have to reboot the machine that I run my X server on or if I want to access the same session from a different machine. This works very well but when restoring a session I'd quite like to just run "emacsclient --create-frame --no-wait" to connect to the daemon without opening a new file. It won't let me get away without specifying a filename.
I've tried using --eval to execute a function rather than open a file but the window just goes away when the evaluation is complete.
(Emacs 23.1 via backports on Debian GNU/Linux 5.0.)
From the help provided by emacsclient, you have a few options. First, is the one mentioned already which is emacsclient -c. That will try to create a frame associated with the emacs daemon. The advantage to this is that if DISPLAY is not set, then it will open emacs in the terminal.
Which brings us to the next best option (especially if you are logging in remotely): emacsclient -t which forces emacs to open up in terminal mode even if DISPLAY is set.
Also keep in mind that you can set the display from the command-line as well. I use this often when logging in remotely from VNC. The full command would be emacsclient -d DISPLAY -c
emacsclient -c works for me.
emacsclient -n -e "(make-frame)"
The -n flag means that the emacsclient doesn't wait, and the emacs instance doesn't destroy the frame.
If you are using emacs from the command line, you might also want to consider emacsclient -t

How do I get the "Command Buffer" in Solaris 10?

When working on a linx CShell u get the option to press the up / down arrows to select the last command/s typed or the Command Buffer. This even works on Windows.
However this is not functional when working on Solaris, to which i recently switched. I am guessing that the shell is also a CShell.
Please tell me what key combination is required to have this feature on Solaris ?
The default shell in Solaris has command history, but you can also use Bash instead, it's more user friendly. Just type 'bash' (no quotes) at the command line. You can also edit /etc/passwd to make bash your default shell.
The "official" default shell for Solaris is actually sh, the original Bourne shell (see Chapter 10 of the Advanced User Guide for Solaris for more info). If you'd like to change it to csh or tcsh—and you're not root (it's generally considered bad practice to use anything but sh as root's default)—just issue passwd -e /path/to/shell_of_your_choice <loginname>. I'm guessing this would probably look like passwd -e /bin/csh <loginname>, but you'd probably want to make sure it exists, first.
It may be that it's the Korn shell in which case try <ESC>k.
bash at least will allow you to switch modes with "set -o vi" or "set -o emacs".
Maybe you can use the !! command, to repeat the previous one.
Use "echo $SHELL" to see what your login shell is. If it's ksh or bash, try "set -o emacs". If that works, you'll be able to use ^P to go back a command. ^R lets you search for a command, ^F and ^B to move around within the command.
If you can´t change your default shell, or you just want to try out one that works, you can kick off any other shell from your command line. I recommend you tcsh, which will have good command line editing and history using the arrow keys. Type /bin/tcsh at your prompt to try it out. You can use the earlier responses to change your default shell if you like tcsh. Make sure your have the following in your $HOME/.cshrc file:
set filec
set history=1000 # or some other large number
set autologout=0 # if you are logging in remotely under your account.
I hope this helps.
You enable history temporarily if you use BASH by typing
HISTSIZE=1000
which will enable up and down keys and store 1000 commands. After termal disconnetion all history will be gone.
This works on solaris 10.
For permanent solution add these lines to ~/.bashrc
HISTSIZE=1000
HISTFILESIZE=1000