I'm trying to use zsh in the CLion terminal window (changed my shell to /bin/zsh)
But when I try to move around using Ctrl + Left, Ctrl + Right, Ctrl + E... I get the literal characters D, C and Ctrl + E opens the "Recent files" UI
Is there any way around this? I'd like to use the movement keystrokes as I can with bash.
Tempoz,
Check out the offical Zsh Line Editor doc and the Z-Shell Line Editor guide for tons of detail.
To start, you can see your current mappings by typing bindkey at your prompt. There are two start modes: emacs [default], and vi. If you want to use vi mode, add this to your ~/.zshrc
bindkey -v
and source it (or restart your shell, or restart your IDE). Check out how the bindkey output has changed.
If you decide you want to change or augment your key mappings, use bind in your ~/.zshrc to reassign, or add to your key map.
# Example key binding change
# bindkey key-sequence editor-command
bindkey '^Z' vi-kill-line
You will also probably want to fix your $PATH - all the JetBrains products do it incorrectly. See this answer: https://stackoverflow.com/a/51006003/1089228
I'm on OSX, and for some reason, when I do command - ← (back arrow) in the PhpStorm terminal I get a [D, while command - → (forward arrow) outputs a [C. What I want to do is jump forward and back one word.
In my OSX terminal these keypresses work as expected, and I can't find anywhere where they are set to output those characters. Does anyone have the answer to this conundrum?
Turns out that an answer for the same problem on iTerm also works for PhpStorm! The fix involves creating a new file named ~/.inputrc and then put the following code in it:
"\e\e[D": backward-word
"\e\e[C": forward-word
Here is the original link
If you are using zsh, add this to ~/.zshrc:
bindkey "\e\eOD" backward-word
bindkey "\e\eOC" forward-word
I recently switch from bash to zsh shell. To be more precise, the oh-my-zsh
Very nice, but the shortcut I most often use; jumping to the beginning/end of the line doesn't work anymore. From the docs it should be
ctrl + A --> beginning
ctrl + E --> end
However, when I do that I get the following
$~> my-command
$~> my-command^A # did a ctrl + A here
Although I see this working by everybody else, on my system something seems to be different. Any suggestions what that might be ?
If you're wondering why this happened: You likely have $EDITOR or $VISUAL set to vi/vim which made zsh default to the vi keymap which doesn't use ctrl+a for moving the caret.
Adding bindkey -e to ~/.zshrc will restore the old behavior (emacs keymap).
you don't have to config the Ctrl+A behavior if you use default keymap (emacs keymap). It does what you are expecting.
However if you set your zle to use vi keymap, you have to define the keybind for vi-beginning-of-line. same for Ctrl+E.
So check which keymap did you set in config. If it was vi, try pressing ESC then ^ and $ should do what you want.
zsh .zshrc
bindkey "^A" vi-beginning-of-line
I've installed the latest vim using homebrew and also installed mac-vim from the google code homepage.
in mac-vim everything works fine. but when I run vim in terminal.app in mac and go to insert mode I'll get A B C D for arrow keys which is extremely annoying.
I googled it and tried all the solutions but nothing is working for me!
it gets intresting when I run vim with vim -u NONE -U NONE -N then the arrow keys start to function normally in insert mode.
my vimrc files are a clone of janus (from carlhuda)
do you have the same problem in terminal? is there a way to fix it in terminal.app?
Just create an empty ".vimrc file in the home directory of the remote machine. It started working fine for me.
touch ~/.vimrc
You need to set no compatible mode in the vim
Try following command in normal mode
:set nocompatible
This works for me:
map ^[[A <up>
map ^[[B <down>
map ^[[C <right>
map ^[[D <left>
To type the sequence for each arrow key, you need to press ctrl-v, then the arrow key.
For example, to type the first line:
m, a, p, space, ctrl-v, ←, space, <, u, p, >
This also might work:
set t_ku=^[[A
set t_kd=^[[B
set t_kr=^[[C
set t_kl=^[[D
More information is available here.
I'm on a MacBook Pro with OSx El Captain (version 10.11.1) and was having the same problem after updating my Vim with Homebrew.
My Vim version is 7.4.1063.
I was having the problem with the Terminal app as well as the iTerm app (build 2.1.4).
To solve this problem, I followed some of the instructions in the previous answers from #devsathish and #Kailash. The steps I followed were:
1 - Create a .vimrc file with touch ~/.vimrc
2 - Add the following to it:
set nocompatible
set backspace=indent,eol,start
Now the arrow keys and the delete/backspace keys work as expected. I didn't have to change my $TERM env variable as suggested in some of the previous answers.
I hope this helps others with the same problem.
I'm using iTerm2 with spf13-vim, and have same problem today.
It caused by removing plugin vim-autoclose. This solution fixed it.
Just add following lines into your .vimrc
if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
inoremap <silent> <C-[>OC <RIGHT>
endif
This is usually caused by the wrong $TERM environment variable. Not sure which ones are supported on your system but you can try with "linux" or "vt320":
export TERM=linux
None of the above worked for me. Running vim in blank state with vim -u NONE -U NONE -N made it work ok, and because I had not installed any plugins, I knew problem is in my vimrc. So I started commenting out sections from it, and at one moment problem disappeared.
The culprit was this line:
inoremap
Even though it was recommended in a very well written course (http://learnvimscriptthehardway.stevelosh.com/chapters/10.html), it broke the arrow keys on Mac OS X 10.10. Basically, you shouldn't overwrite esc, as the other SO answer explains: How to disable Esc and cursor keys in vim
To make sure that my Terminal is working great with Vim 7.3 in Show Leopard, I have done the following:
Installed the latest Vim via Homebrew.
Set path to enable the latest Vim. E.g.: export PATH=/usr/local/bin:$PATH
Added export TERM=linux to my .bashrc file.
Created a .vimrc file with some options (formerly linked here, link went dead.)
When so is done, everything should work. However, I have experienced that some text don't seem to remove, like its protected until I either dd or x. Has anyone experienced something similar? Also, please share comments on my small guide above.
I have used following code in my .vimrc file, and it has resolved my problem with arrow keys.
...
...
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
...
...
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
...
...
I have posted my complete .vimrc file Here. Hope it helps !
This is what worked for me (based on initial solution from #Phoenix above)
imap ^[OA <ESC>kli
imap ^[OB <ESC>jli
imap ^[OC <ESC>lli
imap ^[OD <ESC>hli
for each
^[
type the sequence press ctrl-v, then ESC
I've had a similar problem with another plugin. I solved it by hardcoding these alternative mappings in the script itself, the first line of each pair was problematic, the second line is the fix:
VIM::command "#{map} <Right> :call <SID>#{prefix}KeyPressed(9)<CR>"
VIM::command "#{map} ^[OC :call <SID>#{prefix}KeyPressed(9)<CR>"
VIM::command "#{map} <Left> :call <SID>#{prefix}KeyPressed(23)<CR>"
VIM::command "#{map} ^[OD :call <SID>#{prefix}KeyPressed(23)<CR>"
VIM::command "#{map} <Down> :call <SID>#{prefix}KeyPressed(14)<CR>"
VIM::command "#{map} ^[OB :call <SID>#{prefix}KeyPressed(14)<CR>"
VIM::command "#{map} <Up> :call <SID>#{prefix}KeyPressed(16)<CR>"
VIM::command "#{map} ^[OA :call <SID>#{prefix}KeyPressed(16)<CR>"
^[ is obtained by hitting <C-v><Esc>.
Maybe you can try something like:
map <Right> ^[OC
I actually resolved this on OS X Mavericks (10.9) by removing set noesckeys from ~/.vimrc
I've run into this problem as well. It has multiple causes, but one of them is vim using vi rather than vim behavior by default. Surprisingly, this can be triggered by the location of your vimrc file.
For example, if you delete your .vimrc from your home directory and move the contents to the system-wide vimrc file, vim will start using vi defaults. With the Mac Terminal, this will give you ABCD from arrows in insert mode. Add "set nocompatible" to the system-wide vimrc, which will force vim to use vim defaults, and the arrows will work again.
I'm working with the Vim 7.2 that comes with Mac OS 10.6.1 (Leopard), using the Mac's "Terminal" app. I'd like to use a fancy color scheme. I did this...
:syntax on
Then this...
:colorscheme slate
:colorscheme elflord
:colorscheme desert
etc...
Syntax highlighting is working, but I'm finding that regardless of the scheme I choose, the only colors displayed are the basic Red, Blue, Cyan, Gray, etc.
Is there a way to get the Terminal app to display a larger collection of colors to allow some more subtle schemes?
Create a .vimrc file on your home ~/ folder and then edit it with vim ~/.vimrc. You can try adding syntax on inside ~/.vimrc file. The following command does that:
echo "syntax on" >> ~/.vimrc
It will highlight your code syntax on vim
You need to create file ~/.vimrc and add syntax on in that file
vi ~/.vimrc
syntax on
save the file
and run your vim
Add "syntax on" to the file /usr/share/vim/vimrc and you'll get highlighting in your files every time you edit one.
# vi /usr/share/vim/vimrc
Add this line at the end of the file:
syntax on
Now you'll get highlighting when you edit whatever's file.
The Terminal.app supports AFAIK only 16 colors; iTerm supports more colors or you use mvim (as suggested by Daniel).
You might want to consider using a version of Vim that is a native Mac app (that runs in a window).
MacVim has great color schemes and you can still launch it from Terminal like so:
$ mvim file.txt
That will open your file in a new Vim window.
#ashcatch - Can't leave a comment, but wanted to add that iTerm has other advantages over Terminal.app such as sensible copy and paste (configurable 'word' regex for easy double click selection of paths/urls, middle click paste) and terminal mouse support (:se mouse=a in vi to get mouse text selection, moving of window borders etc.)
I'd be lost without it.