Does vim saving all edits in terminal history? - vim

I have recently noticed a side bar at vim terminal that scrolls all they way to the first command I ran to get vim started. Every time I open an file using NERDTree or close a file I am still working on the same terminal, but the previous snapshots of vim are saved in terminal history. I can scroll all they way to the top and look at every vim command I ran and what file was open during that command.
I have never seen this happen before? Can I turn it off? If I press :q the file that was currently in the terminal shifts up and the new files shows up at the bottom.

Thanks to FDinoff I found the problem. The "term" variable was set incorrectly. I went to my vimrc file and commented out the exact line with "term" and vim now works perfectly fine.

Related

VIm How to fix - Already at oldest change Press ENTER or type command to continue

I read all the other posts on this problem and tried them all. I am posting this since those solutions did not work for me. I am a vim beginner, so part of the problem here is not understanding all the workings of the .vimrc. Still, I need it to work in order to learn.
I added a line to open Chrome with a shortcut and ever since this I get the above message. I've since deleted the line, which never even worked, as well I've tried all the following which came from other posts, deleting each and trying them in combination.
Adding-
set shortmess=a
set cmdheight=2
Adding-
if v:version >= 703
"undo settings
set undodir=~/.vim/undofiles
set undofile
set undolevels=99999
set undolevels=10000
(Point here was to up the undo levels)
Adding- set nomore
When I enter into Vim, and then try to exit with q!, it always makes me enter the command twice. This never used to happen and must be connected to this error.
On vim 7.4, Sierra, regular terminal.
The last time I had some weird behaviour like that in Vim, I had something invalid in my ~/.viminfo file. This file keeps your Vim history: searches, commands, buffers, where you were in files you edited, etc.
My guess is that there are lines in the command line history section that are causing trouble.
To test my theory, rename your ~/.viminfo to some other name (effectively deleting it to Vim) and see if the behaviour is still there. Should that work and you don't mind losing your Vim history, just delete the file. Otherwise you can try to find the offending lines in it, but be careful to work on a differently named copy because Vim writes to this file.

Exit Vim without clearing the terminal before

Every time after I exit Vim, it looks like the "clear" command is called automatically in the shell. Everything left on the screen is a new command line for input.
More exactly, it seems that Vim shares the same terminal with shell. After exiting Vim, the shell commands and their output are pushed pages up, and a "clear" must be called, because otherwise the content in Vim will remain on the screen.
With man and less, there is no such problem. After exiting, the screen returns what it is before running man and less. What can I do so that Vim could act like this?
You can edit ~/.vimrc and add into it set t_ti= t_te=.

How do I cancel a paste operation in Vim?

I had rather a lot of text on my clipboard whenever I accidentally right clicked inside Putty (with Vim open), and Vim has initiated a paste operation which has been going for around ten minutes now.
I don't want to lose my unsaved work, is there a way to instruct Vim to stop pasting text?
If you're in normal mode, Ctrl-C aborts the current command in progress. Then press u to undo anything that changed before you stopped it.
Depending os your vim configuration, there's chances that you have a swap file (backup) in .nameOfTheOpenedFile.swp (substitute nameOfTheOpenedFile with the name for your file).
To recover the file :
vim -r .nameOfTheOpenedFile.swp
I know this is really old but the top answer is not right and I was clearly having a similar issue to OP. (accidentally pasted like a million lines of json into vim)
Keep in mind this may not allow you to save your work (but you can probably salvage something from the .swp file)
All you need to do is open a new terminal window and enter pkill vim into the command line.

VIM: Overwriting system vimrc

I work on multiple MAC OS X systems, which do not save changes after log out. As you know VIM is on every new mac, just type in vim in the terminal. I always bring my vimrc file with me, and the problem is that every single time I start vim i have to load it with :so command.
I want to use the fact that vim is available on every unix, but I also want to take advantage of the nifty integration with the terminal for doing quick tests, I just switch back to the terminal, but for that I need to close vim. When I reopen it, I again have to load the vimrc. And I am a newb, I don't even have plugins yet...
I want to keep the integration with the terminal and only develop a super quick way of introducing my changes to vim. Think of the conditions as if though you are sitting on newly installed operating system.
Thanks !
Not directly to your question, but you can always invoke vim with -u, which will let you specify your vimrc file instead of launching vim and then running :so.
The default location for your .vimrc file is ~/.vimrc (on the mac, ~ is /Users/_you_, eg /Users/matt). If you can write your file there, it will be loaded when vim starts up every time.
The system vimrc file on the mac is at /usr/share/vim/vimrc, but it sounds like these systems are not under your control, so you won't be able to write that file. Have a look at: How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?, which uses the -u option to change the path vim looks for plugins under. But, in all cases, you must either be able to write your .vimrc into your home directory (which it sounds like your system does not permit) or specify the path to it at runtime (as with the command-line option I mention above, or with the normal command :so which you're currently using).
Depending on the kind of testing you need to do, you can always run shell commands within vim, by using the ! in normal mode. For instance, I frequently make changes to a python file in a buffer, and then (in normal mode) run !nosetests within vim—that writes terminal output into a temporary buffer at the bottom, and doesn't require me to leave or suspend vim. I can review the output, and any key-press takes me back to my buffer.
I don't have any experience with Mac-Os terminal. However I think if you could cp your .vimrc file to your home directory. everytime you start vim, vim will load the .vimrc file from your home directory.
If you want to swtich back to terminal from vim to do some testing/execute some commands and back to vim. you could consider to:
open multiple terminal windows
try something like screen or tmux. personaly I am using tmux, and it's very nice.
try Conque Shell plugin: http://www.vim.org/scripts/script.php?script_id=2771 I have this plugin installed too.
type Ctrl-z in vim to back to terminal
If you want to sync your .vimrc on different machines, you could put your .vimrc file in
a scm repository like gitHub, bitbucket... (I perfer this option, since you could have different branches for different settings)
dropbox
I hope this helps.
How is it possible that your changes are not saved after you log out? What would be the point of such a machine? An internet kiosk in an airport? Do you log as a user without a "home" directory?
If you have a "home" directory, just create a blank ~/.vimrc and put your settings there.
If you don't have a "home" directory but you are able to write somewhere else, create a blank vimrc file where you can, write your settings there and learn this command by heart:
$ vim -u /path/to/your/vimrc
If you don't have a "home" directory and you are really sure that you can't save anything on these machines, put your settings in a file somewhere online, preferably a place under your control, and learn this command by heart:
$ vim -u http://domain.name/yourvimrc
If you are lucky, the command you use will be remembered by your shell for you and it will be easy to issue it again without much typing.
For running your tests, you can either:
Hit <C-z> to suspend Vim. You are back at the prompt from where you started Vim and you can do your thing. Type $ fg to go back to Vim.
Type :sh to launch a new shell from the current directory. To go back to Vim, type $ exit.

Every time I run VIM, "help.txt" opens automatically

I'm afraid asking this silly question but google looks like has no answer for this.
Every time I run VIM in terminal it automatically opens "help.txt" file with sp(split screen) mode.
It says "help.txt" "help.txt" [readonly] 217L, 8055C
Does anybody knows how to fix this problem?
in my case it was because I am using app called caffeine (prevents PC from sleeping) which is simulating pressing F15. After I change it status to inactive, it stopped opening vim help in terminal window.
Try running:
vim -u NONE
If this help file doesn't appear when doing that, then there's something in a vimrc file somewhere that is opening the help. Check in:
~/.vimrc
/usr/share/vim/vimrc
/etc/vimrc
...and anywhere else you might find a vimrc file on your system.
if you run
$ vim -u NONE
and the issue persists, maybe (like in my case) is some software simulating a key press to prevent the system from sleep.
try to change it for another key, like shift, and not f15.
good luck!

Resources