Blue Flower

How To Stop Vim (vi) From Tracking (Logging/Recording) All Your Actions When You Use Vim On A File

Introduction

On Unix, Linux, and *ix servers, when you text edit a file using Vim, all your actions and some options choices are logged into a file of .viminfo.  So, all your changes, and what you thought you deleted is still reflected in that .viminfo file.  It also allows you to edit another file and scroll through searches you did while working on a previous file.  There are huge benefits for having this automated logging, but that is not what this article is about.  It does not matter what file you edit, when you use the Vim (vi) software, the logging occurs.  So, if you accidentally typed or pasted a password into the command line and edited the .bash_history file to remove it's mentions, then know that it still shows in the .viminfo file.  If you try to edit the .viminfo file by deleting the lines that show things you do not want, those changes will be logged and updated to the .viminfo file.  So, if you edit the .viminfo file itself and close it and then open it again, you will see what you removed continue to be mentioned in some form.  So, as you can see there are times when you will want the logging turned off, and that is easily done.

 

To Turn Off Logging While Using Vim

When editing any file type the following:

:set viminfo=

The above will turn off the logging of your actions when using Vim (vi).

 

Choosing Selective Logging

 I have also collected the following that allows you to selectively turn of or log specific things.  After the = sign, you can indicate Switches that enable (turn on) or disable (turn off) behaviors.

 

  • '0 means that marks will not be saved.
  • :0 means that command line history will not be saved.
  • <0 means that registers will not be saved.
  • @0 means that input line history will not be saved.
  • f0 means that marks will not be saved.
  • % means it saves buffer and restores the buffer list.
  • / means that the search history will not be saved.  The default is to save the search history.
  • n indicates where to save the viminfo files.
  • '10  means marks will be remembered for up to 10 previously edited files.
  • "100 means it will save up to 100 lines for each register.
  • :20  means  up to 20 lines of command line history will be stored.

Example: :set viminfo='0,:0,<0,@0,f0,n~/.viminfo
The / is not used in the above example, and so search history would be saved.

Example: :set viminfo='50,\"1000,:0,n~/vim/viminfo

Example: :set viminfo='10,\"100,:20,%,nc:\\owner\\Windows\\_viminfo
In this case, what follows after n indicates the file system path on a windows operating system.

The above should work for many versions of VIM, including 7.2, and 7.4.
You can access the Vim Help, while using Vim, by typing :h 'viminfo'.

 

What Does Or Can .viminfo Store?

The viminfo file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of registers.
- Marks for several files.
- File marks, pointing to locations in files; such as cursor position.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.
- Deletions and additions (as implied above).

 

Feel Free To Leave A Good Comment. :)

Look around, and you may find other useful articles. Add this site to your Bookmarks/Favorites for easy return for new articles. Consider submitting technical articles for publication, including your embedded links. I will even create a new category if needed.