Vim Tips Wiki
Register
Advertisement

Use this page to discuss script 2775 logpad: emulate Notepad's logging functionality

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

logpad.vim is a plug-in that adds Notepad.exe's logging functionality to Vim. It was inspired by this German weblog posting.

What does it do?[]

Let me explain what is actually meant by using notepad.exe:

Imagine you want to, let's say, log some things happening outside, UFOs flying by or something. Open notepad.exe, write .LOG as the first line and save it.

Logpad.notepad.1

Now reopen the file. The editor added a time stamp with a new line where you can take your notes, like "another UFO! THEY COME! SCREEEEAAAAAM!", and it adds a new one every time you open the file again:

Logpad.notepad.2

And this is exactly what logpad.vim does!

Configuration[]

This plug-in has some options you can tweak by setting them in your Vim configuration files. Allowed values for value are 0 and 1.

Enable/Disable the plug-in[]

  • let LogpadEnabled = value
    • enables/disables logpad
    • default value: 1

If you set this option to "0", logpad.vim will do nothing at all.

Automatically switch to insert mode[]

  • let LogpadInsert = value
    • automatically enables &insertmode when a new log entry is created
    • default value: 0

Given that you only want to add new entries when using logpad.vim, you may want to enable this option. Note that you will have to use C-o then in order to use Vim's mighty input key bindings.

Add more line breaks[]

  • let LogpadLineBreak = value
    • adds an empty line before a new log entry
    • default value: 0 (Windows Notepad behavior)

By default, no line breaks are added, so your log might look a bit confusing after adding a few entries. If you enable this option, you will get a new line break before all entries (even before the first one).

Enable me to write some intro[]

  • let LogpadIgnoreNotes = value
    • allows adding notes before the first log entry
    • default value: 0

Logpad.vim allows you to write some introductional text before your actual log, so everything between .LOG and the first time stamp is considered valid. You can also use this option to stop the plug-in from processing certain files by just writing some dummy text below the first line and not changing this option to 1.

Ignore a log file's read-only state[]

  • let LogpadIgnoreReadOnly = value
    • allows logpad to ignore a file's read-only flag
    • default value: 0

Under certain conditions it might be possible that your log file is read-only even if you actually have write access to it. If this happens, set this option to 1, so logpad.vim does not care about the read-only flag.

Known issues[]

Logpad.vim's timestamps are not "portable", so it won't recognize German timestamps on an English system. For now you'd better avoid sharing them.

Comments[]

Advertisement