How can Vim stop responding? - session

With an intention to increment a number in a line in Vim, I pressed Ctrl+A. To my wonder Vim stopped responding! Later I realized that I had actually pressed Ctrl+S.
Can somebody please explain this behavior?
I've made some changes to the file, but not saved before vim stopped responding.
(Aside: Ctrl+X decreases the next number on the line)

You've stopped the terminal with CTRL-S. To resume, press CTRL-Q.
Btw, this is not VIM-specific, but rather terminal-specific.

To disable the Ctrl-S/ Ctrl-Q completely from your terminal, add the following line to your .bashrc :
stty -ixon

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 to add new line in bashrc file in ubuntu?

I'm trying to update my bashrc file in ubuntu with some environment variables.
I can do this using below command.
echo 'export APP=/opt/tinyos-2.x/apps' >> ~/.bashrc
But I want to do it manually, meaning open the file with vim editor then add it.
The problem here is when I open the bashrc file the end line is "fi" and when I reach there and press insert and then enter to go to new line it stays at the same line and moves the fi word only or create A or C or B random characters.
May I know please some commands to handle this bashrc file so that I could add a new line and then my variables over there?
I've tried to look online but didn't find what am looking for.
Since you didn't specify if you have terminal access only or also GUI.
If you have terminal access only, any editor would do it.
Popular editors like nano or vim come installed by default in most Ubuntu releases.
To use nano, in your terminal, type
nano ~/.bashrc
Then press Ctrl + w +v to go to the end, add what you want to add, the Ctrl + o to save changes, Ctrl +x to exit.
You will need to log out and log back on, or run source ~/.profile to make your changes available to your bash environment.
Here's what you can do in vim.
Press the letter G. It will take you to the last line.
Press the letter O. It will allow you to insert text after the current lne.
Type in your content - export APP=/opt/tinyos-2.x/apps
Press the ESC key get out of editing mode.
Press the key :. It will allow you type commands.
Type wq followed by Enter. This will save the file and quit vim.
You are done.
As you are using Vim/Vi editor you need to use i/insert key to start editing, then for saving use escape & then wq to save and exit. For More detailed instructions please visit this link
Honestly, learning vim in a week (or even in a day) is tough. Took me more than a month to actually be productive on it as mh daily editor. But just to tell you. Go to the line after which you want to ass a new line using H-J-K-L or arrow keys. Then presss o. It'll spawn a new line below it and go into insert mode as well. Then write and press Esc. Enter :wq.

MobaXterm The fist character of bash prompt is showing up on a different line, how do I fix this?

When I type in a command in MobaXterm, the first character of my prompt shows up at the end of the next line, and the rest of the prompt is on the line after. It doesn't seem to affect anything performance-wise, but I can't seem to find anyone else with this issue. If anyone has any ideas as to what might be causing this, some help would be much appreciated.
screenshot of my terminal
On a MobaXterm window, Click on Settings->Configuration and then in the Terminal tab un-select Display separation line.
Click here for a picture
This is not due to a setting in MobaXterm, but rather it is due to the default prompt set in the version of bash cygwin installed by MobaXterm, which adds a newline.
You can change the prompt by setting PS1 in ~/.bash_profile (or if you set it up ~/.bashrc). For example I add this line and now there is no newline at the prompt:
PS1="\h [\e[33m]\w[\e[0m]> "

Sending signal to bash shell launched in GVim

How do I send a signal (say, SIGINT), to a shell launched inside GVim, using a keyboard shortcut?
Neither Ctrl+C nor Ctrl+D seem to work.
Ctrl+D seems to work for me, at least for closing a terminal session. Crl+C however does not. If you only want to kill a running process, you can do this workaround (provided Ctrl+Z) works for you.
Press Ctrl+Z to pause the process, then
kill %1
to kill the process in the background.
Inside vim, use command :shto temporarily exit vim and go to shell
If you want to go back to vim then press Ctrl + D. This work for me for years.

VI editor "ESC" key and "Ctrl + [" do not work correctly

I am a complete beginner with VI editor.
I had a chance of using the VI editor by typing git commit instead of git commit -m "my comment" when commenting my commit to my git repository.
I learned that I would go into "edit" mode by pressing i in the VI command line. And I also learned that I go back to the command mode by pressing either ESC key or Ctrl + [ key combination. However, neither keys get me out of the "edit" mode.
What happens is that pressing either keys do the same thing, something that seems like accumulating ESC key. Each time I press either key, I see something like below in the bottom line of the screen:
Pressed once:
ESC-
Pressed twice:
ESC ESC-
Pressed three times:
ESC ESC ESC
Since I know that the command to save and exit is :wq, when I press ESC one time and followed by :, the command line immediately turns into to Eval:. It seems like ESC + : is the key combination for such command.
This seems weird. What would be the problem and how could I fix it?
Thanks in advance for your help.
Edit
I found the below codes from .gitconfig file in my root directory. Is this causing the problem?
[core]
autocrlf = input
safecrlf = true
editor = emacs
SOLVED! My problem was due to the [core] editor part of the global settings of .gitconfig. Once I changed it to editor = vi I was able to exit out using VI's shortcuts. Thanks everybody for helping me out.
It is possible that there is something in your ~/.vimrc file that is causing problems. You might try moving your .vimrc file to a temporary one, then start vim basically without a configuration and see if the problem persists. If it does then put the file back and start commenting things out until you find it.
It is also possible that your terminal is passing through weird keystrokes or something.

Resources