Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started working on a proper parser for note taking syntax

  • Loading branch information...
commit 907c2a293ed869d0f32f88aa687f5d89559560be 1 parent 96024ad
@xolox authored
Showing with 368 additions and 287 deletions.
  1. +1 −0  addon-info.json
  2. +116 −0 autoload/xolox/notes/parser.vim
  3. +251 −287 doc/notes.txt
View
1  addon-info.json
@@ -0,0 +1 @@
+{"vim_script_nr": 3375, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/notes", "name": "vim-notes"}
View
116 autoload/xolox/notes/parser.vim
@@ -0,0 +1,116 @@
+" Vim auto-load script
+" Author: Peter Odding <peter@peterodding.com>
+" Last Change: June 23, 2013
+" URL: http://peterodding.com/code/vim/notes/
+
+function! xolox#notes#parser#parse_note(text) " {{{1
+ " Parser for the note taking syntax used by vim-notes.
+ let context = s:create_parse_context(a:text)
+ let note_title = context.next_line()
+ let blocks = [{'type': 'title', 'text': note_title}]
+ while context.has_more()
+ let chr = context.peek()
+ if chr == '#'
+ " Parse the upcoming heading in the input stream.
+ let block = s:parse_heading(context)
+ else
+ " Parse the upcoming paragraph in the input stream.
+ let block = s:parse_paragraph(context)
+ endif
+ " Don't include empty blocks in the output.
+ if !empty(block)
+ call add(blocks, block)
+ endif
+ endwhile
+ return blocks
+endfunction
+
+function! s:create_parse_context(text) " {{{1
+ " Create an object to encapsulate the lowest level of parser state.
+ let context = {'text': a:text, 'index': 0}
+ " The has_more() method returns 1 (true) when more input is available, 0
+ " (false) otherwise.
+ function context.has_more()
+ return self.index < len(self.text)
+ endfunction
+ " The peek() method returns the next character without consuming it.
+ function context.peek()
+ return self.has_more() ? self.text[self.index] : ''
+ endfunction
+ " The next() method returns the next character and consumes it.
+ function context.next()
+ let chr = self.peek()
+ let self.index += 1
+ return chr
+ endfunction
+ " The next_line() method returns the current line and consumes it.
+ function context.next_line()
+ let line = ''
+ while self.has_more()
+ let chr = self.next()
+ if chr == "\n" || chr == ""
+ " We hit the end of line or input.
+ return line
+ else
+ " The line continues.
+ let line .= chr
+ endif
+ endwhile
+ return line
+ endfunction
+ return context
+endfunction
+
+function! s:parse_heading(context) " {{{1
+ " Parse the upcoming heading in the input stream.
+ let level = 0
+ while a:context.peek() == '#'
+ let level += 1
+ call a:context.next()
+ endwhile
+ let text = xolox#misc#str#trim(a:context.next_line())
+ return {'type': 'heading', 'level': level, 'text': text}
+endfunction
+
+function! s:parse_paragraph(context) " {{{1
+ " Parse the upcoming paragraph in the input stream.
+ let lines = []
+ while a:context.has_more()
+ let line = a:context.next_line()
+ if empty(line)
+ break
+ endif
+ call add(lines, line)
+ endwhile
+ " Don't include empty paragraphs in the output.
+ let text = join(lines, "\n")
+ if text =~ '\S'
+ return {'type': 'paragraph', 'text': text}
+ else
+ return {}
+ endif
+endfunction
+
+function! xolox#notes#parser#run_tests() " {{{1
+ " Tests for the note taking syntax parser.
+ call xolox#misc#test#reset()
+ call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_note_titles')
+ call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_headings')
+ call xolox#misc#test#wrap('xolox#notes#parser#test_parsing_of_paragraphs')
+ call xolox#misc#test#summarize()
+endfunction
+
+function! xolox#notes#parser#test_parsing_of_note_titles()
+ call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}], xolox#notes#parser#parse_note('Just the title'))
+endfunction
+
+function! xolox#notes#parser#test_parsing_of_headings()
+ call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'heading', 'level': 1, 'text': 'This is a heading'}], xolox#notes#parser#parse_note("Just the title\n\n# This is a heading"))
+endfunction
+
+function! xolox#notes#parser#test_parsing_of_paragraphs()
+ call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'paragraph', 'text': 'This is a paragraph'}], xolox#notes#parser#parse_note("Just the title\n\nThis is a paragraph"))
+ call xolox#misc#test#assert_equals([{'type': 'title', 'text': 'Just the title'}, {'type': 'paragraph', 'text': 'This is a paragraph'}, {'type': 'paragraph', 'text': "And here's another paragraph!"}], xolox#notes#parser#parse_note("Just the title\n\nThis is a paragraph\n\n\n\nAnd here's another paragraph!"))
+endfunction
+
+call xolox#notes#parser#run_tests()
View
538 doc/notes.txt
@@ -1,14 +1,13 @@
*notes.txt* Easy note taking in Vim
===============================================================================
- *notes-contents*
Contents ~
- 1. Introduction |notes-introduction|
- 2. Install & usage |notes-install-usage|
- 3. Options |notes-options|
+ 1. Introduction |notes-introduction|
+ 2. Install & usage |notes-install-usage|
+ 3. Options |notes-options|
1. The |g:notes_directories| option
- 1. Backwards compatibility |notes-backwards-compatibility|
+ 1. Backwards compatibility |notes-backwards-compatibility|
2. The |g:notes_suffix| option
3. The |g:notes_title_sync| option
4. The |g:notes_smart_quotes| option
@@ -20,155 +19,158 @@ Contents ~
10. The |g:notes_indexfile| option
11. The |g:notes_indexscript| option
12. The |g:notes_tagsindex| option
- 4. Commands |notes-commands|
+ 4. Commands |notes-commands|
1. The |:Note| command
2. The |:NoteFromSelectedText| command
3. The |:SplitNoteFromSelectedText| command
4. The |:TabNoteFromSelectedText| command
5. The |:DeleteNote| command
6. The |:SearchNotes| command
- 1. |:SearchNotes| understands @tags
+ 1. |:SearchNotes| understands @tags |searchnotes-understands-tags|
2. Accelerated searching with Python |notes-accelerated-searching-with-python|
7. The |:RelatedNotes| command
8. The |:RecentNotes| command
9. The |:MostRecentNote| command
10. The |:ShowTaggedNotes| command
11. The |:IndexTaggedNotes| command
- 5. Mappings |notes-mappings|
- 1. Insert mode mappings |notes-insert-mode-mappings|
- 6. Customizing the syntax highlighting of notes
- 7. Other plug-ins that work well with the notes plug-in
- 1. utl.vim |notes-utl.vim|
- 2. shell.vim |notes-shell.vim|
- 3. VOoM |notes-voom|
- 4. Txtfmt |notes-txtfmt|
- 8. Contact |notes-contact|
- 9. License |notes-license|
+ 5. Mappings |notes-mappings|
+ 1. Insert mode mappings |notes-insert-mode-mappings|
+ 6. Customizing the syntax highlighting of notes |customizing-syntax-highlighting-of-notes|
+ 7. Other plug-ins that work well with the notes plug-in |other-plug-ins-that-work-well-with-notes-plug-in|
+ 1. utl.vim |notes-utl.vim|
+ 2. shell.vim |notes-shell.vim|
+ 3. VOoM |notes-voom|
+ 4. Txtfmt |notes-txtfmt|
+ 8. Contact |notes-contact|
+ 9. License |notes-license|
+ 10. References |notes-references|
===============================================================================
- *notes-introduction*
+ *notes-introduction*
Introduction ~
The vim-notes plug-in for the Vim text editor makes it easy to manage your
notes in Vim:
- - Starting a new note: Execute the |:Note| command to create a new buffer and
- load the appropriate file type and syntax
+- **Starting a new note:** Execute the |:Note| command to create a new buffer
+ and load the appropriate file type and syntax
- - You can also start a note with Vim commands like ':edit', ':tabedit' and
- ':split' by starting the filename with 'note:', as in ':edit note:todo'
- (the part after 'note:' doesn't have to be the complete note title and if
- it's empty a new note will be created)
+- You can also start a note with Vim commands like ':edit', ':tabedit' and
+ ':split' by starting the filename with 'note:', as in ':edit note:todo'
+ (the part after 'note:' doesn't have to be the complete note title and if
+ it's empty a new note will be created)
- - You can start a new note with the selected text as title in the current
- window using the '\en' mapping or |:NoteFromSelectedText| command (there
- are similar mappings and commands for opening split windows and tab pages)
+- You can start a new note with the selected text as title in the current
+ window using the '\en' mapping or |:NoteFromSelectedText| command (there
+ are similar mappings and commands for opening split windows and tab pages)
- - Saving notes: Just use Vim's |:write| and |:update| commands, you don't need to
- provide a filename because it will be set based on the title (first line)
- of your note (you also don't need to worry about special characters,
- they'll be escaped)
+- **Saving notes:** Just use Vim's |:write| and |:update| commands, you don't
+ need to provide a filename because it will be set based on the title (first
+ line) of your note (you also don't need to worry about special characters,
+ they'll be escaped)
- - Editing existing notes: Execute ':Note anything' to edit a note containing
- 'anything' in its title (if no notes are found a new one is created with
- its title set to 'anything')
+- **Editing existing notes:** Execute ':Note anything' to edit a note
+ containing 'anything' in its title (if no notes are found a new one is
+ created with its title set to 'anything')
- - The |:Note| and |:DeleteNote| commands support tab completion of note titles
+- The |:Note| and |:DeleteNote| commands support tab completion of note
+ titles
- - Deleting notes: The |:DeleteNote| command enables you to delete the current
- note
+- **Deleting notes:** The |:DeleteNote| command enables you to delete the
+ current note
- - Searching notes: ':SearchNotes keyword …' searches for keywords and
- ':SearchNotes /pattern/' searches for regular expressions
+- **Searching notes:**':SearchNotes keyword …' searches for keywords and
+ ':SearchNotes /pattern/' searches for regular expressions
- - The |:SearchNotes| command supports tab completion of keywords and sorts
- candidates by relevance (Levenshtein distance [1])
+- The |:SearchNotes| command supports tab completion of keywords and sorts
+ candidates by relevance (Levenshtein distance [1])
- - Smart defaults: Without an argument |:SearchNotes| searches for the word
- under the cursor (if the word starts with '@' that character will be
- included in the search, this means you can easily search for @tagged notes)
+- **Smart defaults:** Without an argument |:SearchNotes| searches for the
+ word under the cursor (if the word starts with '@' that character will be
+ included in the search, this means you can easily search for _@tagged_
+ notes)
- - Back-references: The |:RelatedNotes| command find all notes referencing the
- current file
+- **Back-references:** The |:RelatedNotes| command find all notes referencing
+ the current file
- - A Python 2 [2] script is included that accelerates keyword searches using a
- keyword index
+- A Python 2 [2] script is included that accelerates keyword searches using a
+ keyword index
- - The |:RecentNotes| command lists your notes by modification date, starting
- with the most recently edited note
+- The |:RecentNotes| command lists your notes by modification date, starting
+ with the most recently edited note
- - Navigating between notes: The included syntax script highlights note names
- as hyper links and the file type plug-in redefines |gf| to jump between notes
- (the Control-w f (see |CTRL-W_f|) mapping to jump to a note in a split window
- and the Control-w gf (see |CTRL-W_gf|) mapping to jump to a note in a new tab
- page also work)
+- **Navigating between notes:** The included syntax script highlights note
+ names as hyper links and the file type plug-in redefines |gf| to jump
+ between notes (the Control-w f (see |CTRL-W_f|) mapping to jump to a note
+ in a split window and the Control-w gf (see |CTRL-W_gf|) mapping to jump to
+ a note in a new tab page also work)
- - Writing aids: The included file type plug-in contains mappings for automatic
- curly quotes, arrows and list bullets and supports completion of note
- titles using Control-X Control-U and completion of tags using Control-X
- Control-O
+- **Writing aids:** The included file type plug-in contains mappings for
+ automatic curly quotes, arrows and list bullets and supports completion of
+ note titles using Control-X Control-U and completion of tags using
+ Control-X Control-O
- - Embedded file types: The included syntax script supports embedded
- highlighting using blocks marked with '{{{type … }}}' which allows you to
- embed highlighted code and configuration snippets in your notes
+- **Embedded file types:** The included syntax script supports embedded
+ highlighting using blocks marked with '{{{type … }}}' which allows you to
+ embed highlighted code and configuration snippets in your notes
Here's a screen shot of the syntax mode using the Slate [3] color scheme and
the font Monaco [4]:
- Syntax mode screen shot, see reference [5]
+ Image: Syntax mode screen shot (see reference [5])
===============================================================================
- *notes-install-usage*
+ *notes-install-usage*
Install & usage ~
-Please note that the vim-notes plug-in requires my vim-misc plug-in which is
-separately distributed.
+_Please note that the vim-notes plug-in requires my vim-misc plug-in which is
+separately distributed._
-Unzip the most recent ZIP archives of the vim-notes [6] and vim-misc [7]
-plug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX
-and '%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command
+Unzip the most recent ZIP archives of the vim-notes [6] and vim-misc [7] plug-
+ins inside your Vim profile directory (usually this is '~/.vim' on UNIX and
+'%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command
':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on Windows). To
get started execute |:Note| or ':edit note:', this will start a new note that
-contains instructions on how to continue from there (and how to use the
-plug-in in general).
+contains instructions on how to continue from there (and how to use the plug-in
+in general).
If you prefer you can also use Pathogen [8], Vundle [9] or a similar tool to
install & update the vim-notes [10] and vim-misc [11] plug-ins using a local
clone of the git repository.
===============================================================================
- *notes-options*
+ *notes-options*
Options ~
-All options have reasonable defaults so if the plug-in works after
-installation you don't need to change any options. The options are available
-for people who like to customize how the plug-in works. You can set these
-options in your |vimrc| script by including a line like this:
+All options have reasonable defaults so if the plug-in works after installation
+you don't need to change any options. The options are available for people who
+like to customize how the plug-in works. You can set these options in your
+|vimrc| script by including a line like this:
>
- :let g:notes_directories = ['~/Documents/Notes', '~/Dropbox/Shared Notes']
-
+ :let g:notes_directories = ['~/Documents/Notes', '~/Dropbox/Shared Notes']
+<
Note that after changing an option in your |vimrc| script you have to restart
Vim for the changes to take effect.
-------------------------------------------------------------------------------
The *g:notes_directories* option
-Your notes are stored in one or more directories. This option defines where
-you want to store your notes. Its value should be a list (there's an example
-above) with one or more pathnames. The default is a single value which depends
-on circumstances but should work for most people:
+Your notes are stored in one or more directories. This option defines where you
+want to store your notes. Its value should be a list (there's an example above)
+with one or more pathnames. The default is a single value which depends on
+circumstances but should work for most people:
- - If the profile directory where the plug-in is installed is writable, the
- directory 'misc/notes/user' under the profile directory is used. This is
- for compatibility with Pathogen [8]; the notes will be stored inside the
- plug-in's bundle.
+- If the profile directory where the plug-in is installed is writable, the
+ directory 'misc/notes/user' under the profile directory is used. This is
+ for compatibility with Pathogen [8]; the notes will be stored inside the
+ plug-in's bundle.
- - If the above doesn't work out, the default depends on the platform:
- '~/vimfiles/misc/notes/user' on Windows and '~/.vim/misc/notes/user' on
- other platforms.
+- If the above doesn't work out, the default depends on the platform:
+ '~/vimfiles/misc/notes/user' on Windows and '~/.vim/misc/notes/user' on
+ other platforms.
-------------------------------------------------------------------------------
- *notes-backwards-compatibility*
+ *notes-backwards-compatibility*
Backwards compatibility ~
In the past the notes plug-in only supported a single directory and the
@@ -178,10 +180,10 @@ notes directories was introduced the option was renamed to
pathnames.
For backwards compatibility with old configurations (all of them as of this
-writing :-) the notes plug-in still uses 'g:notes_directory' when it is
-defined (its no longer defined by the plug-in). However when the plug-in warns
-you to change your configuration you probably should because this
-compatibility will be removed at some point.
+writing :-) the notes plug-in still uses 'g:notes_directory' when it is defined
+(its no longer defined by the plug-in). However when the plug-in warns you to
+change your configuration you probably should because this compatibility will
+be removed at some point.
-------------------------------------------------------------------------------
The *g:notes_suffix* option
@@ -192,8 +194,8 @@ filenames don't include an extension like '.txt'. You can use this option to
make the plug-in automatically append an extension without having to embed the
extension in the note's title, e.g.:
>
- :let g:notes_suffix = '.txt'
-
+ :let g:notes_suffix = '.txt'
+<
-------------------------------------------------------------------------------
The *g:notes_title_sync* option
@@ -201,12 +203,11 @@ When you rename a file in your notes directory but don't change the title, the
plug-in will notice this the next time you open the note in Vim. Likewise when
you change the title in another text editor but don't rename the file. By
default the plug-in will prompt you whether you want it to update the title of
-the note, rename the file on disk or dismiss the prompt without doing
-anything.
+the note, rename the file on disk or dismiss the prompt without doing anything.
-If you set this option to the string 'no' this feature will be completely
-disabled. If you set it to 'change_title' it will automatically change the
-title to match the filename. If you set it to 'rename_file' it will
+If you set this option to the string "'no'" this feature will be completely
+disabled. If you set it to "'change_title'" it will automatically change the
+title to match the filename. If you set it to "'rename_file'" it will
automatically rename the file on disk to match the title.
-------------------------------------------------------------------------------
@@ -218,26 +219,26 @@ with curly quotes. The full list of substitutions can be found below in the
documentation on mappings. If you don't want the plug-in to perform these
substitutions, you can set this option to zero like this:
>
- :let g:notes_smart_quotes = 0
-
+ :let g:notes_smart_quotes = 0
+<
-------------------------------------------------------------------------------
The *g:notes_ruler_text* option
-The text of the ruler line inserted when you type '***' in quick succession.
-It defaults to three asterisks separated by spaces, center aligned to the text
+The text of the ruler line inserted when you type '***' in quick succession. It
+defaults to three asterisks separated by spaces, center aligned to the text
width.
-------------------------------------------------------------------------------
The *g:notes_list_bullets* option
-A list of characters used as list bullets. When you're using a Unicode
-encoding this defaults to '['•', '◦', '▸', '▹', '▪', '▫']', otherwise it
-defaults to '['*', '-', '+']'.
+A list of characters used as list bullets. When you're using a Unicode encoding
+this defaults to "['•', '◦', '▸', '▹', '▪', '▫']", otherwise it defaults to
+"['*', '-', '+']".
When you change the nesting level (indentation) of a line containing a bullet
point using one of the mappings 'Tab', 'Shift-Tab', 'Alt-Left' and 'Alt-Right'
-the bullet point will be automatically changed to correspond to the new
-nesting level.
+the bullet point will be automatically changed to correspond to the new nesting
+level.
The first level of list items gets the first bullet point in
|g:notes_list_bullets|, the second level gets the second, etc. When you're
@@ -252,17 +253,17 @@ By default 'Tab' is mapped to indent list items and 'Shift-Tab' is mapped to
dedent list items. You can disable these mappings by adding the following to
your |vimrc| script:
>
- :let g:notes_tab_indents = 0
-
+ :let g:notes_tab_indents = 0
+<
-------------------------------------------------------------------------------
The *g:notes_alt_indents* option
By default 'Alt-Right' is mapped to indent list items and 'Alt-Left' is mapped
-to dedent list items. You can disable these mappings by adding the following
-to your |vimrc| script:
+to dedent list items. You can disable these mappings by adding the following to
+your |vimrc| script:
>
- :let g:notes_alt_indents = 0
-
+ :let g:notes_alt_indents = 0
+<
-------------------------------------------------------------------------------
The *g:notes_shadowdir* option
@@ -285,26 +286,26 @@ accelerated keyword searching with |:SearchNotes|.
-------------------------------------------------------------------------------
The *g:notes_tagsindex* option
-This option defines the pathname of the text file that stores the list of
-known tags used for tag name completion and the |:ShowTaggedNotes| command.
-The text file is created automatically when it's first needed, after that you
-can recreate it manually by executing |:IndexTaggedNotes| (see below).
+This option defines the pathname of the text file that stores the list of known
+tags used for tag name completion and the |:ShowTaggedNotes| command. The text
+file is created automatically when it's first needed, after that you can
+recreate it manually by executing |:IndexTaggedNotes| (see below).
===============================================================================
- *notes-commands*
+ *notes-commands*
Commands ~
To edit one of your existing notes (or create a new one) you can use Vim
-commands such as |:edit|, |:split| and |:tabedit| with a filename that starts with
-note: followed by (part of) the title of one of your notes, e.g.:
+commands such as |:edit|, |:split| and |:tabedit| with a filename that starts
+with _note:_ followed by (part of) the title of one of your notes, e.g.:
>
- :edit note:todo
-
+ :edit note:todo
+<
This shortcut also works from the command line:
>
- $ gvim note:todo
-
-When you don't follow note: with anything a new note is created like when you
+ $ gvim note:todo
+<
+When you don't follow _note:_ with anything a new note is created like when you
execute |:Note| without any arguments.
-------------------------------------------------------------------------------
@@ -312,23 +313,23 @@ The *:Note* command
When executed without any arguments this command starts a new note in the
current window. If you pass one or more arguments the command will edit an
-existing note containing the given words in the title. If more than one note
-is found you'll be asked which note you want to edit. If no notes are found a
-new note is started with the given word(s) as title.
+existing note containing the given words in the title. If more than one note is
+found you'll be asked which note you want to edit. If no notes are found a new
+note is started with the given word(s) as title.
This command will fail when changes have been made to the current buffer,
unless you use ':Note!' which discards any changes.
-When you are using multiple directories to store your notes and you run
-|:Note| while editing an existing note, a new note will inherit the directory
-of the note from which you started. Otherwise the note is created in the first
+When you are using multiple directories to store your notes and you run |:Note|
+while editing an existing note, a new note will inherit the directory of the
+note from which you started. Otherwise the note is created in the first
directory in |g:notes_directories|.
-This command supports tab completion: If you complete one word, all existing
+_This command supports tab completion:_ If you complete one word, all existing
notes containing the given word somewhere in their title are suggested. If you
-type more than one word separated by spaces, the plug-in will complete only
-the missing words so that the resulting command line contains the complete
-note title and nothing more.
+type more than one word separated by spaces, the plug-in will complete only the
+missing words so that the resulting command line contains the complete note
+title and nothing more.
-------------------------------------------------------------------------------
The *:NoteFromSelectedText* command
@@ -367,43 +368,44 @@ made to the buffer, unless you use ':DeleteNote!' which discards any changes.
-------------------------------------------------------------------------------
The *:SearchNotes* command
-This command wraps |:vimgrep| and enables you to search through your notes using
-one or more keywords or a regular expression pattern. To search for a pattern
-you pass a single argument that starts/ends with a slash:
+This command wraps |:vimgrep| and enables you to search through your notes
+using one or more keywords or a regular expression pattern. To search for a
+pattern you pass a single argument that starts/ends with a slash:
>
- :SearchNotes /TODO\|FIXME\|XXX/
-
+ :SearchNotes /TODO\|FIXME\|XXX/
+<
To search for one or more keywords you can just omit the slashes, this matches
notes containing all of the given keywords:
>
- :SearchNotes syntax highlighting
-
+ :SearchNotes syntax highlighting
+<
-------------------------------------------------------------------------------
-|:SearchNotes| understands @tags ~
+ *searchnotes-understands-tags*
+:SearchNotes understands @tags ~
If you don't pass any arguments to the |:SearchNotes| command it will search
for the word under the cursor. If the word under the cursor starts with '@'
this character will be included in the search, which makes it possible to
-easily add @tags to your @notes and then search for those tags. To make
+easily add _@tags_ to your _@notes_ and then search for those tags. To make
searching for tags even easier you can create key mappings for the
|:SearchNotes| command:
>
- " Make the C-] combination search for @tags:
- imap <C-]> <C-o>:SearchNotes<CR>
- nmap <C-]> :SearchNotes<CR>
-
- " Make double mouse click search for @tags. This is actually quite a lot of
- " fun if you don't use the mouse for text selections anyway; you can click
- " between notes as if you're in a web browser:
- imap <2-LeftMouse> <C-o>:SearchNotes<CR>
- nmap <2-LeftMouse> :SearchNotes<CR>
-
+ " Make the C-] combination search for @tags:
+ imap <C-]> <C-o>:SearchNotes<CR>
+ nmap <C-]> :SearchNotes<CR>
+
+ " Make double mouse click search for @tags. This is actually quite a lot of
+ " fun if you don't use the mouse for text selections anyway; you can click
+ " between notes as if you're in a web browser:
+ imap <2-LeftMouse> <C-o>:SearchNotes<CR>
+ nmap <2-LeftMouse> :SearchNotes<CR>
+<
These mappings are currently not enabled by default because they conflict with
already useful key mappings, but if you have any suggestions for alternatives
feel free to contact me through GitHub or at peter@peterodding.com.
-------------------------------------------------------------------------------
- *notes-accelerated-searching-with-python*
+ *notes-accelerated-searching-with-python*
Accelerated searching with Python ~
After collecting a fair amount of notes (say more than 5 MB) you will probably
@@ -412,8 +414,8 @@ notes. To make searching more scalable the notes plug-in includes a Python
script which uses a persistent full text index of your notes stored in a file.
The first time the Python script is run it will need to build the complete
-index which can take a moment, but after the index has been initialized
-updates and searches should be more or less instantaneous.
+index which can take a moment, but after the index has been initialized updates
+and searches should be more or less instantaneous.
-------------------------------------------------------------------------------
The *:RelatedNotes* command
@@ -428,8 +430,8 @@ The *:RecentNotes* command
If you execute the |:RecentNotes| command it will open a Vim buffer that lists
all your notes grouped by the day they were edited, starting with your most
recently edited note. If you pass an argument to |:RecentNotes| it will filter
-the list of notes by matching the title of each note against the argument
-which is interpreted as a Vim pattern.
+the list of notes by matching the title of each note against the argument which
+is interpreted as a Vim pattern.
-------------------------------------------------------------------------------
The *:MostRecentNote* command
@@ -441,15 +443,15 @@ between restarts of Vim and is shared between all instances of Vim.
-------------------------------------------------------------------------------
The *:ShowTaggedNotes* command
-To show a list of all notes that contains @tags you can use the
+To show a list of all notes that contains _@tags_ you can use the
|:ShowTaggedNotes| command. If you pass a count to this command it will limit
the list of tags to those that have been used at least this many times. For
example the following two commands show tags that have been used at least ten
times:
>
- :10ShowTaggedNotes
- :ShowTaggedNotes 10
-
+ :10ShowTaggedNotes
+ :ShowTaggedNotes 10
+<
-------------------------------------------------------------------------------
The *:IndexTaggedNotes* command
@@ -458,154 +460,116 @@ complete the names of tags. To trigger the omni completion you type Control-X
Control-O. When you type '@' in insert mode the plug-in will automatically
start omni completion.
-The completion menu is populated from a text file listing all your tags, one
-on each line. The first time omni completion triggers, an index of tag names
-is generated and saved to the location set by |g:notes_tagsindex|. After this
-file is created, it will be updated automatically as you edit notes and
-add/remove tags.
+The completion menu is populated from a text file listing all your tags, one on
+each line. The first time omni completion triggers, an index of tag names is
+generated and saved to the location set by |g:notes_tagsindex|. After this file
+is created, it will be updated automatically as you edit notes and add/remove
+tags.
If for any reason you want to recreate the list of tags you can execute the
|:IndexTaggedNotes| command.
===============================================================================
- *notes-mappings*
+ *notes-mappings*
Mappings ~
The following key mappings are defined inside notes.
-------------------------------------------------------------------------------
- *notes-insert-mode-mappings*
+ *notes-insert-mode-mappings*
Insert mode mappings ~
- - '@' automatically triggers tag completion
-
- - '' becomes '‘' or '’' depending on where you type it
-
- - '"' becomes '“' or '”' (same goes for these)
-
- - '--' becomes '—'
-
- - '->' becomes '->'
-
- - '<-' becomes '←'
-
- - the bullets '*', '-' and '+' become '•'
-
- - the three characters '***' in insert mode in quick succession insert a
- horizontal ruler delimited by empty lines
-
- - 'Tab' and 'Alt-Right' increase indentation of list items (works on the
- current line and selected lines)
-
- - 'Shift-Tab' and 'Alt-Left' decrease indentation of list items
-
- - 'Enter' on a line with only a list bullet removes the bullet and starts a
- new line below the current line
-
- - '\en' executes |:NoteFromSelectedText|
-
- - '\sn' executes |:SplitNoteFromSelectedText|
-
- - '\tn' executes |:TabNoteFromSelectedText|
+- '@' automatically triggers tag completion
+- "'" becomes '‘' or '’' depending on where you type it
+- '"' becomes '“' or '”' (same goes for these)
+- '--' becomes '—'
+- '->' becomes '→'
+- '<-' becomes '←'
+- the bullets '*', '-' and '+' become '•'
+- the three characters '***' in insert mode in quick succession insert a
+ horizontal ruler delimited by empty lines
+- 'Tab' and 'Alt-Right' increase indentation of list items (works on the
+ current line and selected lines)
+- 'Shift-Tab' and 'Alt-Left' decrease indentation of list items
+- 'Enter' on a line with only a list bullet removes the bullet and starts a
+ new line below the current line
+- '\en' executes |:NoteFromSelectedText|
+- '\sn' executes |:SplitNoteFromSelectedText|
+- '\tn' executes |:TabNoteFromSelectedText|
===============================================================================
+ *customizing-syntax-highlighting-of-notes*
Customizing the syntax highlighting of notes ~
-The syntax mode for notes is written so you can override styles you don't
-like. To do so you can add lines such as the following to your |vimrc| script:
+The syntax mode for notes is written so you can override styles you don't like.
+To do so you can add lines such as the following to your |vimrc| script:
>
- " Don't highlight single quoted strings.
- highlight link notesSingleQuoted Normal
-
- " Show double quoted strings in italic font.
- highlight notesDoubleQuoted gui=italic
-
+ " Don't highlight single quoted strings.
+ highlight link notesSingleQuoted Normal
+
+ " Show double quoted strings in italic font.
+ highlight notesDoubleQuoted gui=italic
+<
See the documentation of the |:highlight| command for more information. Below
are the names of the syntax items defined by the notes syntax mode:
- - 'notesName' - the names of other notes, usually highlighted as a hyperlink
-
- - 'notesTagName' - words preceded by an '@' character, also highlighted as a
- hyperlink
-
- - 'notesListBullet' - the bullet characters used for list items
-
- - 'notesListNumber' - numbers in front of list items
-
- - 'notesDoubleQuoted' - double quoted strings
-
- - 'notesSingleQuoted' - single quoted strings
-
- - 'notesItalic' - strings between two '_' characters
-
- - 'notesBold' - strings between two '*' characters
-
- - 'notesTextURL' - plain domain name (recognized by leading 'www.')
-
- - 'notesRealURL' - URLs (e.g. http://vim.org/)
-
- - 'notesEmailAddr' - e-mail addresses
-
- - 'notesUnixPath' - UNIX file paths (e.g. '~/.vimrc' and '/home/peter/.vimrc')
-
- - 'notesPathLnum' - line number following a UNIX path
-
- - 'notesWindowsPath' - Windows file paths (e.g. 'c:\users\peter\_vimrc')
-
- - 'notesTodo' - 'TODO' markers
-
- - 'notesXXX' - 'XXX' markers
-
- - 'notesFixMe' - 'FIXME' markers
-
- - 'notesDoneItem' - lines containing the marker 'DONE', usually highlighted as
- a comment
-
- - 'notesDoneMarker' - 'DONE' markers
-
- - 'notesVimCmd' - Vim commands, words preceded by an ':' character
-
- - 'notesTitle' - the first line of each note
-
- - 'notesShortHeading' - short sentences ending in a ':' character
-
- - 'notesAtxHeading' - lines preceded by one or more '#' characters
-
- - 'notesBlockQuote' - lines preceded by a '>' character
-
- - 'notesRule' - lines containing only whitespace and '* * *'
-
- - 'notesCodeStart' - the '{{{' markers that begin a block of code (including
- the syntax name)
-
- - 'notesCodeEnd' - the '}}}' markers that end a block of code
-
- - 'notesModeLine' - Vim |modeline| in last line of notes
-
- - 'notesLastEdited' - last edited dates in |:ShowTaggedNotes| buffers
+- 'notesName' - the names of other notes, usually highlighted as a hyperlink
+- 'notesTagName' - words preceded by an '@' character, also highlighted as a
+ hyperlink
+- 'notesListBullet' - the bullet characters used for list items
+- 'notesListNumber' - numbers in front of list items
+- 'notesDoubleQuoted' - double quoted strings
+- 'notesSingleQuoted' - single quoted strings
+- 'notesItalic' - strings between two '_' characters
+- 'notesBold' - strings between two '*' characters
+- 'notesTextURL' - plain domain name (recognized by leading 'www.')
+- 'notesRealURL' - URLs (e.g. http://vim.org/)
+- 'notesEmailAddr' - e-mail addresses
+- 'notesUnixPath' - UNIX file paths (e.g. '~/.vimrc' and
+ '/home/peter/.vimrc')
+- 'notesPathLnum' - line number following a UNIX path
+- 'notesWindowsPath' - Windows file paths (e.g. 'c:\users\peter\_vimrc')
+- 'notesTodo' - 'TODO' markers
+- 'notesXXX' - 'XXX' markers
+- 'notesFixMe' - 'FIXME' markers
+- 'notesDoneItem' - lines containing the marker 'DONE', usually highlighted
+ as a comment
+- 'notesDoneMarker' - 'DONE' markers
+- 'notesVimCmd' - Vim commands, words preceded by an ':' character
+- 'notesTitle' - the first line of each note
+- 'notesShortHeading' - short sentences ending in a ':' character
+- 'notesAtxHeading' - lines preceded by one or more '#' characters
+- 'notesBlockQuote' - lines preceded by a '>' character
+- 'notesRule' - lines containing only whitespace and '* * *'
+- 'notesCodeStart' - the '{{{' markers that begin a block of code (including
+ the syntax name)
+- 'notesCodeEnd' - the '}}}' markers that end a block of code
+- 'notesModeLine' - Vim |modeline| in last line of notes
+- 'notesLastEdited' - last edited dates in |:ShowTaggedNotes| buffers
===============================================================================
+ *other-plug-ins-that-work-well-with-notes-plug-in*
Other plug-ins that work well with the notes plug-in ~
-------------------------------------------------------------------------------
- *notes-utl.vim*
+ *notes-utl.vim*
utl.vim ~
The utl.vim [12] universal text linking plug-in enables links between your
notes, other local files and remote resources like web pages.
-------------------------------------------------------------------------------
- *notes-shell.vim*
+ *notes-shell.vim*
shell.vim ~
My shell.vim [13] plug-in also enables easy navigation between your notes and
-environment like local files and directories, web pages and e-mail addresses
-by providing key mappings and commands to e.g. open the file/URL under the
-text cursor. This plug-in can also change Vim to full screen which can be
-really nice for large notes.
+environment like local files and directories, web pages and e-mail addresses by
+providing key mappings and commands to e.g. open the file/URL under the text
+cursor. This plug-in can also change Vim to full screen which can be really
+nice for large notes.
-------------------------------------------------------------------------------
- *notes-voom*
+ *notes-voom*
VOoM ~
The VOoM [14] outlining plug-in should work well for notes if you use the
@@ -614,7 +578,7 @@ this combination may not always work so well in practice (sometimes losing
notes!)
-------------------------------------------------------------------------------
- *notes-txtfmt*
+ *notes-txtfmt*
Txtfmt ~
If the text formatting supported by the notes plug-in is not enough for you,
@@ -622,11 +586,11 @@ consider trying the Txtfmt [15] (The Vim Highlighter) plug-in. To use the two
plug-ins together, create the file 'after/ftplugin/notes.vim' inside your Vim
profile with the following contents:
>
- " Enable Txtfmt formatting inside notes.
- setlocal filetype=notes.txtfmt
-
+ " Enable Txtfmt formatting inside notes.
+ setlocal filetype=notes.txtfmt
+<
===============================================================================
- *notes-contact*
+ *notes-contact*
Contact ~
If you have questions, bug reports, suggestions, etc. the author can be
@@ -635,14 +599,14 @@ http://peterodding.com/code/vim/notes/ and http://github.com/xolox/vim-notes.
If you like the script please vote for it on Vim Online [16].
===============================================================================
- *notes-license*
+ *notes-license*
License ~
-This software is licensed under the MIT license [17]. Copyright 2013 Peter
-Odding <peter@peterodding.com>.
+This software is licensed under the MIT license [17]. © 2013 Peter Odding
+<peter@peterodding.com>.
===============================================================================
- *notes-references*
+ *notes-references*
References ~
[1] http://en.wikipedia.org/wiki/Levenshtein_distance
Please sign in to comment.
Something went wrong with that request. Please try again.