diff --git a/README.md b/README.md index 8443ba8..a10f271 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,14 @@ This command will fail when changes have been made to the current buffer, unless ### The `:NoteFromSelectedText` command -When you execute this command it will start a new note with the selected text as the title of the note. +Start a new note in the current window with the selected text as the title of the note. The name of this command isn't very well suited to daily use, however the idea is that users will define their own mapping to invoke this command. For example: + + " Map \ns in visual mode to start new note with selected text as title. + vmap ns :NoteFromSelectedText + +### The `:SplitNoteFromSelectedText` command + +Same as `:NoteFromSelectedText` but opens the new note in a vertical split window. ### The `:DeleteNote` command diff --git a/autoload/xolox/notes.vim b/autoload/xolox/notes.vim index b6be560..1ff6735 100644 --- a/autoload/xolox/notes.vim +++ b/autoload/xolox/notes.vim @@ -6,7 +6,7 @@ " Note: This file is encoded in UTF-8 including a byte order mark so " that Vim loads the script using the right encoding transparently. -let g:xolox#notes#version = '0.14.6' +let g:xolox#notes#version = '0.15' function! xolox#notes#shortcut() " {{{1 " The "note:" pseudo protocol is just a shortcut for the :Note command. @@ -101,11 +101,10 @@ function! xolox#notes#check_sync_title() " {{{1 endif endfunction -function! xolox#notes#from_selection(bang) " {{{1 - " TODO This will always open a new buffer in the current window which I - " don't consider very friendly (because the user loses his/her context), - " but choosing to always split the window doesn't seem right either... - call xolox#notes#edit(a:bang, s:get_visual_selection()) +function! xolox#notes#from_selection(bang, cmd) " {{{1 + let selection = s:get_visual_selection() + if a:cmd != 'edit' | execute a:cmd | endif + call xolox#notes#edit(a:bang, selection) endfunction function! s:get_visual_selection() diff --git a/doc/notes.txt b/doc/notes.txt index 84646e8..b6aab04 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -11,8 +11,9 @@ notes in Vim: (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 using the - |:NoteFromSelectedText| command + - You can start a new note with the selected text as title in the current + window using the |:NoteFromSelectedText| command (the |:SplitNoteFromSelectedText| + command opens the new note in a split window) - 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) @@ -47,9 +48,11 @@ notes in Vim: - The |:RecentNotes| command lists your notes by modification date, starting with the most recently edited note - - Navigating between notes: The included file type plug-in redefines |gf| to - jump between notes and the syntax script highlights note names as hyper - links + - 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 @@ -208,8 +211,19 @@ note title and nothing more. ------------------------------------------------------------------------------- The *:NoteFromSelectedText* command -When you execute this command it will start a new note with the selected text -as the title of the note. +Start a new note in the current window with the selected text as the title of +the note. The name of this command isn't very well suited to daily use, +however the idea is that users will define their own mapping to invoke this +command. For example: +> + " Map \ns in visual mode to start new note with selected text as title. + vmap ns :NoteFromSelectedText + +------------------------------------------------------------------------------- +The *:SplitNoteFromSelectedText* command + +Same as |:NoteFromSelectedText| but opens the new note in a vertical split +window. ------------------------------------------------------------------------------- The *:DeleteNote* command diff --git a/plugin/notes.vim b/plugin/notes.vim index 7da1d2d..7c2e516 100644 --- a/plugin/notes.vim +++ b/plugin/notes.vim @@ -1,6 +1,6 @@ " Vim plug-in " Author: Peter Odding -" Last Change: November 23, 2011 +" Last Change: November 25, 2011 " URL: http://peterodding.com/code/vim/notes/ " Support for automatic update using the GLVS plug-in. @@ -57,7 +57,8 @@ endif " User commands to create, delete and search notes. command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete Note call xolox#notes#edit(, ) -command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection() +command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(, 'edit') +command! -bar -bang -range SplitNoteFromSelectedText call xolox#notes#from_selection(, 'vsplit') command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete DeleteNote call xolox#notes#delete(, ) command! -bang -nargs=? -complete=customlist,xolox#notes#keyword_complete SearchNotes call xolox#notes#search(, ) command! -bar -bang RelatedNotes call xolox#notes#related()