Skip to content

Commit cde86b4

Browse files
committed
New command :SplitNoteFromSelectedText
1 parent 43f5a10 commit cde86b4

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ This command will fail when changes have been made to the current buffer, unless
104104

105105
### The `:NoteFromSelectedText` command
106106

107-
When you execute this command it will start a new note with the selected text as the title of the note.
107+
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:
108+
109+
" Map \ns in visual mode to start new note with selected text as title.
110+
vmap <Leader>ns :NoteFromSelectedText<CR>
111+
112+
### The `:SplitNoteFromSelectedText` command
113+
114+
Same as `:NoteFromSelectedText` but opens the new note in a vertical split window.
108115

109116
### The `:DeleteNote` command
110117

autoload/xolox/notes.vim

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.14.6'
9+
let g:xolox#notes#version = '0.15'
1010

1111
function! xolox#notes#shortcut() " {{{1
1212
" The "note:" pseudo protocol is just a shortcut for the :Note command.
@@ -101,11 +101,10 @@ function! xolox#notes#check_sync_title() " {{{1
101101
endif
102102
endfunction
103103

104-
function! xolox#notes#from_selection(bang) " {{{1
105-
" TODO This will always open a new buffer in the current window which I
106-
" don't consider very friendly (because the user loses his/her context),
107-
" but choosing to always split the window doesn't seem right either...
108-
call xolox#notes#edit(a:bang, s:get_visual_selection())
104+
function! xolox#notes#from_selection(bang, cmd) " {{{1
105+
let selection = s:get_visual_selection()
106+
if a:cmd != 'edit' | execute a:cmd | endif
107+
call xolox#notes#edit(a:bang, selection)
109108
endfunction
110109

111110
function! s:get_visual_selection()

doc/notes.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ notes in Vim:
1111
(the part after 'note:' doesn't have to be the complete note title and if
1212
it's empty a new note will be created)
1313

14-
- You can start a new note with the selected text as title using the
15-
|:NoteFromSelectedText| command
14+
- You can start a new note with the selected text as title in the current
15+
window using the |:NoteFromSelectedText| command (the |:SplitNoteFromSelectedText|
16+
command opens the new note in a split window)
1617

1718
- Saving notes: Just use Vim's |:write| and |:update| commands, you don't need to
1819
provide a filename because it will be set based on the title (first line)
@@ -47,9 +48,11 @@ notes in Vim:
4748
- The |:RecentNotes| command lists your notes by modification date, starting
4849
with the most recently edited note
4950

50-
- Navigating between notes: The included file type plug-in redefines |gf| to
51-
jump between notes and the syntax script highlights note names as hyper
52-
links
51+
- Navigating between notes: The included syntax script highlights note names
52+
as hyper links and the file type plug-in redefines |gf| to jump between notes
53+
(the Control-w f (see |CTRL-W_f|) mapping to jump to a note in a split window
54+
and the Control-w gf (see |CTRL-W_gf|) mapping to jump to a note in a new tab
55+
page also work)
5356

5457
- Writing aids: The included file type plug-in contains mappings for automatic
5558
curly quotes, arrows and list bullets and supports completion of note
@@ -208,8 +211,19 @@ note title and nothing more.
208211
-------------------------------------------------------------------------------
209212
The *:NoteFromSelectedText* command
210213

211-
When you execute this command it will start a new note with the selected text
212-
as the title of the note.
214+
Start a new note in the current window with the selected text as the title of
215+
the note. The name of this command isn't very well suited to daily use,
216+
however the idea is that users will define their own mapping to invoke this
217+
command. For example:
218+
>
219+
" Map \ns in visual mode to start new note with selected text as title.
220+
vmap <Leader>ns :NoteFromSelectedText<CR>
221+
222+
-------------------------------------------------------------------------------
223+
The *:SplitNoteFromSelectedText* command
224+
225+
Same as |:NoteFromSelectedText| but opens the new note in a vertical split
226+
window.
213227

214228
-------------------------------------------------------------------------------
215229
The *:DeleteNote* command

plugin/notes.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: November 23, 2011
3+
" Last Change: November 25, 2011
44
" URL: http://peterodding.com/code/vim/notes/
55

66
" Support for automatic update using the GLVS plug-in.
@@ -57,7 +57,8 @@ endif
5757

5858
" User commands to create, delete and search notes.
5959
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete Note call xolox#notes#edit(<q-bang>, <q-args>)
60-
command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>)
60+
command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'edit')
61+
command! -bar -bang -range SplitNoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'vsplit')
6162
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete DeleteNote call xolox#notes#delete(<q-bang>, <q-args>)
6263
command! -bang -nargs=? -complete=customlist,xolox#notes#keyword_complete SearchNotes call xolox#notes#search(<q-bang>, <q-args>)
6364
command! -bar -bang RelatedNotes call xolox#notes#related(<q-bang>)

0 commit comments

Comments
 (0)