Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New command :SplitNoteFromSelectedText

  • Loading branch information...
commit cde86b40ef44adc26613a4af6533ffacc02e4c03 1 parent 43f5a10
@xolox authored
View
9 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 <Leader>ns :NoteFromSelectedText<CR>
+
+### The `:SplitNoteFromSelectedText` command
+
+Same as `:NoteFromSelectedText` but opens the new note in a vertical split window.
### The `:DeleteNote` command
View
11 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()
View
28 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 <Leader>ns :NoteFromSelectedText<CR>
+
+-------------------------------------------------------------------------------
+The *:SplitNoteFromSelectedText* command
+
+Same as |:NoteFromSelectedText| but opens the new note in a vertical split
+window.
-------------------------------------------------------------------------------
The *:DeleteNote* command
View
5 plugin/notes.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" 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(<q-bang>, <q-args>)
-command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>)
+command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'edit')
+command! -bar -bang -range SplitNoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'vsplit')
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete DeleteNote call xolox#notes#delete(<q-bang>, <q-args>)
command! -bang -nargs=? -complete=customlist,xolox#notes#keyword_complete SearchNotes call xolox#notes#search(<q-bang>, <q-args>)
command! -bar -bang RelatedNotes call xolox#notes#related(<q-bang>)

0 comments on commit cde86b4

Please sign in to comment.
Something went wrong with that request. Please try again.