I have now published this as a new plugin at vim.org called "Notes":

http://www.vim.org/scripts/script.php?script_id=2732

I would appreciate any feedback. Here is the description from the script page:

-----------------------
If you like to keep your notes in clear text files, Vim is of course
the best editor you could use to edit. This plugin simply makes it
easier to create, open, move, search etc. these notes using custom
commands, all without having to leave the comfort of Vim.

Each note is a separate text file that is saved under a common root
configured using g:notesRoot. You can open these note files just like
any other file or use the :Note command with command-line completion
to make it easier.

Starting to take a new note should be as simple as typing :Note. Enter
your text and save to generate a name automatically based on the first
line. You can also start typing in an unnamed buffer (created using
<Ctrl-W>n) and later convert it as a note using :NoteAsNew command
(again named automatically based on the first line).

If you prefer, you can organize the notes into subfolders using your
favorite file browser (in or outside Vim) while the :NoteNewFolder and
:NoteMove commands from the plugin simplify certain operations from
within Vim.

Features:
- Start a new note with less number of keystrokes and less thinking
- Automatic name generation
- Ease of opening with command-line completion
- Searching for patterns
- Ease of organizing

Here is the documentation that can also be found in the header of
plugin/notes.vim.
Usage:
  - In vimrc, :let g:notesRoot to the root directory holding/containing all
    your notes.
  - Use ":Note" command to create or open note files.
  - All note files are regular text files, but they are special to the
    plugin only if they live under the g:notesRoot directory.
  - You can also open existing note files by using regular vim commands or
    file browsers. However, ":Note" command provides completion that could
    make it easier to find a note.
  - Usage: Note [<path>]
      - With no arguments, it creates a new note in the root.
      - When the <path> is not absolute, it is handled relative to the root.
        - When <path> resolves to an existing directory, a new note is
          created in that directory.
        - When <path> resolves to an existing file, the file is opened as a
          note.
        - When <path> resolves to a non existing name, a new note is created
          with that name.
      - Absolute paths to (existing or non-existing) files or (existing)
        directories can also be specified, but they should refer to paths
        under the root.
  - You can use ":NoteNewFolder" to create subdirectories under the root with
    the convenience of completion. This works very much like mkdir command
    and specifying "!" is equivalent to "-p" option.
  - Use ":NoteMove <path>" to move the current note to the destination. It
    behaves pretty much like the mv command except that relative paths are
    relative to the root of the notes directory (g:notesRoot) and provides
    directory name completion.
  - Use :NoteAsNew command instead of :w to save notes taken in an unnamed
    buffer with an auto-generated name under the root directory.
  - ":NoteGrep[!] <pat>" command is a shortcut to invoke :vimgrep on the
    subfolder. If the pattern is not enclosed, it will be automatically
    enclosed in /'es.  If the pattern itself has /'es or you need to pass
    flags, then you need to enclose the pattern yourself with any flags at
    the end. See help on :vimgrep for details.
  - ":NoteBrowse" is a simple shortcut to open the root directory, which
    will open the directory in your default file explorer.
  - ":NoteSyncFilename" sync the filename of the note to the first line in
    the note. This is to manually trigger the process when
    g:notesSyncNameAndTitle is disabled (see below).

  Settings:
  - g:notesRoot - Sets the root directory path. Required for the plugin to
                  load.
  - g:notesDefaultName - The default name used for notes (without any
                         extension). Defaults to "New Note" when not
                         defined.
  - g:notesMaxNameLenth - An integer that limits the length of generated names.
                          Defaults to 100 when not defined.
  - g:notesSyncNameAndTitle - Allows automatically renaming notes on save,
                              based on the first non-empty line. When
                              disabled, use :NoteSyncFilename to manually
                              trigger this. Defaults to 1 when not defined.
  - g:notesFileExtension - The extension for the notes files. When no
                           extension is specififed to the note, this
                           extension will be automatically added. Defaults
                           to '.txt' when not defined.
  - g:notesFileType - The 'filetype' set when a note is opened. Useful to set
                      along with the g:ntotesFileExtension, if you are
                      editing notes created with markup (e.g., to edit wiki
                      notes, set FileExtension to '.wiki' and the FileType
                      to 'wiki'). Defaults to "note", but not filetype
                      plugins are provided for this type by the plugin.
Notes:
  When a note is opened, the 'filetype' of the buffer is set to "note". This
  means, you can create an ftplugin/note.vim file anywhere in your 'rtp' for
  buffer specific settings, such as 'indent', 'expandtab'. You can also
  initialize the buffer with some text. E.g., place the below code in your
  after/ftplugin/note.vim to automatically create a header for your new note
  files:
      " Means, it is an empty buffer
      if line('$') == 1 && getline(1) == ''
        call append(1, substitute(expand('%:t'), '\.\w\+$', '', '').':')
        normal! G
      endif
-----------------------

-- 
Hari



On Fri, Jul 31, 2009 at 1:08 PM, Hari Krishna Dara<[email protected]> wrote:
> On Wed, Jul 29, 2009 at 7:21 AM, Toni Ruottu<[email protected]> wrote:
>>
>> I'm glad to see someone working on this. I'm rather busy at the
>> moment, but I'm willing to test it once it is supposed to work. In
>> case the script becomes stable, would turning it into a standard
>> feature. I'm ok with using some special command for storing the
>> current buffer into a note (instead of a file), but I'll probably be
>> too lazy to install an extension on each system separately.
>>
>>  --toni
>>
>
> I am attaching a plugin but you do need to install it on each system
> separately. However, it is very simple to do so, just unzip it into
> your .vim/vimfiles directory and add one line to your vimrc (e.g., let
> g:notesRoot = "c:/notes"). I wouldn't expect this to be part of core
> vim functionality, as it is something that can be achieved using a
> plugin like this, however some changes to the core could help improve
> the experience (e.g., there is no way to trap :w on an unnamed buffer,
> Vim simply gives an error, no matter what autocommands are defined).
>
> Judging by your previous messages, here is how I think you would use the 
> plugin:
> - Type :Note command with no arguments when you start taking a new
> note consciously. Save the note just like any other file using :w
> command.
> - Start typing in an unnamed buffer, but use :NoteAsNew command when
> you are done. Unfortunately, :w at this point will give you the same
> error message that you are familiar with and despise, but at least you
> don't have to think about a filename and location, if you simply use
> :NoteAsNew.
>
> Feel free to define maps for the above commands to make it easier to
> use them. I have some more documentation below (which is also
> available in the plugin/notes.vim file) that describes the additional
> functionality. I have been using the plugin for myself (as I said I
> wanted it myself) and find it usable, but feedback from others will
> help shape it better.
>
> - In vimrc, let g:notesRoot to the root directory holding/containing
> all your notes.
> - Use ":Note" command to create or open notes.
> - All note files are regular text files, but they are special to the
>  plugin only if they live under the g:notesRoot directory.
> - You can also open existing note files by using regular vim commands or
>  file browsers. However, ":Note" command provies completion that could
>  make it easier to find a note.
> - Usage: Note [<relPathToDir>|<name>|<fullPathToDir>|<fullPathToName>]
>         <no arguments> - create a new note in the root.
>        <relPathToDir>  - create a new note in an existing subdir
>                          under root.
>                 <name> - create a new note or open an existing note with
>                          the specified name in the root dir.
>        <fullPathToDir> - to create a new note under the specified
>                          path (path should be under root)
>       <fullPathToName> - to create a new note or open an existing
>                          note with the specified path.
> - You can use ":NoteNewFolder" to create subdirectories under the root with
>  the convenience of completion.
> - Use ":NoteSyncFilename[!]" to sync the filename of the note to the first 
> line
>  in the note. This is to trigger the process when g:notesSyncNameAndTitle
>  is disabled (see below). Use bang to force a save when the buffer is
>  modified.
> - Use :NoteAsNew command instead of :w to save notes taken in an unnamed
>  buffer with an autogenerated name under the root directory.
> - ":NoteGrep[!] <pat>" command is a shortcut to invoke :vimgrep on the
>  subfolder. If the pattern is not enclosed, it will be automatically
>  enclosed in /'es.  If the pattern itself has /'es or you need to pass
>  flags, then you need to enclose the pattern yourself with any flags at
>  the end. See help on vimgrep for details.
> - ":NoteBrowse" is a simple shortcut to open the root directory, which
>  will open the directory in your default file explorer.
>
> Settings:
> - g:notesRoot - Sets the root directory path.
> - g:notesDefaultName - The default name used for notes (without any
>                       extension)
> - g:notesMaxNameLenth - An integer that limits the length of generated names.
> - g:notesSyncNameAndTitle - Allows automatically renaming notes on save,
>                            based on the first non-empty line. When
>                            disabled, use :NoteSyncFilename to manually
>                            trigger this.
>
> --
> Hari
>

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui