Disable cmd+k when using Vim in terminal? - macos

So when I'm using Vim in the mac osx terminal I accidentally enter the command cmd+k that clears my terminal because I'm used to the motion, this makes me have to exit vim and enter again. I want to know if theres a way to disable this.
For example this is me editing my .vimrc
Then I enter the command and my terminal looks like this:
Is there a way to disable this command when using Vim only? I want to continue using it when using the terminal outside Vim. Thanks

Instead of restarting vim use CTRL-L to redraw the screen.

Related

Print terminal command output directly into vim - macOS

Whenever I enter a terminal command in vim (e.g., !echo hello), I am momentarily kicked out to view the result of that terminal command and then prompted with Press ENTER or type command to continue. This is a bit jarring. I would like to stay within vim and with the command output printed out at the bottom.
I know vim :read will take the terminal output and actually put it into my buffer, but that is not what I am looking to do. Here is some reading if you are interested in a tangent.
It looks like when I run vim in Screen I get what I am looking for, but I am trying to get this to work with tmux and the stock Mac terminal.
After a ton of research, probably too much, I got it! It looks like vim will send commands to the terminal, which in turn defines the behavior of how the terminal commands are processed from vim. Put this into your .vimrc file:
set t_ti= t_te= " show results from terminal commands within vim!
From what I understand, this just makes sure to send nothing to the terminal, which yields my desired results!
Side note: the above addition to your .vimrc file will also prevent the vim buffer from clearing when exiting vim (e.g., :wq). I am okay with this! It is kind of nice sometimes to see what you were just working on :).

how do you enable command line editing with vim keys using mac terminal?

I'm reading this book and I really do not understand what this author is talking about. It appears that you can program your mac to go forward one character by either hitting l or ^F. I do not understand the difference between emac key stroke and vim keystroke. He also says run this command and 'place it in your $HOME/.bash_profile but I cannot figure out how to place the command in the bas_profile.
The Author is talking about make you terminal console behaves like vi, this means typing set -o vi in your terminal, the console will work similar vi. So you will be able to navigate using the motion keys of vi, use INSERT mode, x to delete, etc.
You can set that permanently if you include this command in your ~/.bash_profile file.
If you are not sure what it does, I don't recommend so.

Emacs Through Putty

So I opened emacs through putty by executing the command "emacs -nw FILENAME", where emacs opens up with the desired file. I split the screen in emacs in order to open different file by executing the command "C-x 2" in emacs to split the window horizontally so that I can view two windows at a time.
My question is, now that I can view both files next to each other through the split screen, how do I edit the other file? (I can't use the mouse to click on the other file (other split window) to edit it because I can only use key commands when using emacs through putty)
You might want to try the Emacs tutorial which will explain those things. Also, I believe it is possible to get mouse clicks to work under putty: try M-x xterm-mouse-mode.
Use C-x o, other-window.
See http://www.gnu.org/software/emacs/manual/html_node/emacs/Other-Window.html.
Another tip to use the other window as a terminal is to run:
M-x term

Why does tmux erase terminal contents on editor exit?

Say I'm running tmux and use "ls" to get something on the screen. Then I enter Vim to edit some file. After exiting Vim, tmux erases whatever text is above the bash prompt (not like the clear command since the prompt stays in the same place).
Is there a way to prevent this behavior? I'm using tmux 1.3 in Terminal.app on OS X.
If your version of tmux has this option, add this line to your ~/.tmux.conf:
set-window-option -g alternate-screen on
Try putting this in your .vimrc file:
set t_ti= t_te=

How can I activate Vim color schemes in OS X's Terminal?

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.

Resources