Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable naming new notes with :NewNote arguments

:NewNote doesn't warn about existing notes with the same name because one
of my next commits will rename :NewNote to :Note and make it open existing
notes instead of creating a new buffer with the same name (to avoid
confusion / accidental overwriting of notes).
  • Loading branch information...
commit 94e10b3bbdc2b609bcbf38e8f3f57dce60137e80 1 parent 16f4600
Peter Odding authored
Showing with 10 additions and 6 deletions.
  1. +8 −4 autoload.vim
  2. +2 −2 notes.vim
12 autoload.vim
View
@@ -1,6 +1,6 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: December 25, 2010
+" Last Change: December 28, 2010
" URL: http://peterodding.com/code/vim/notes/
" Note: This file is encoded in UTF-8 including a byte order mark so
@@ -8,7 +8,7 @@
let s:script = expand('<sfile>:p:~')
-function! xolox#notes#new(bang) " {{{1
+function! xolox#notes#new(bang, name) " {{{1
" Create a new note using the :NewNote command.
if !s:is_empty_buffer()
execute 'enew' . a:bang
@@ -16,7 +16,11 @@ function! xolox#notes#new(bang) " {{{1
setlocal filetype=notes
execute 'silent read' fnameescape(xolox#path#merge(g:notes_shadowdir, 'New note'))
1delete
- setlocal nomodified
+ if a:name =~ '\S'
+ call setline(1, xolox#trim(a:name))
+ else
+ setlocal nomodified
+ endif
doautocmd BufReadPost
endfunction
@@ -59,7 +63,7 @@ function! xolox#notes#shortcut() " {{{1
let filename = ''
let arguments = xolox#trim(matchstr(expand('<afile>'), 'note:\zs.*'))
if arguments == ''
- call xolox#notes#new(bang)
+ call xolox#notes#new(bang, '')
return
endif
for [fname, title] in items(xolox#notes#get_fnames_and_titles())
4 notes.vim
View
@@ -3,7 +3,7 @@
" Last Change: December 28, 2010
" URL: http://peterodding.com/code/vim/notes/
" License: MIT
-" Version: 0.7.20
+" Version: 0.7.21
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3375 1 :AutoInstall: session.zip
@@ -37,7 +37,7 @@ if !exists('g:notes_indexscript')
endif
" User commands to create, delete and search notes.
-command! -bar -bang NewNote call xolox#notes#new(<q-bang>)
+command! -bar -bang -nargs=? NewNote call xolox#notes#new(<q-bang>, <q-args>)
command! -bar -bang DeleteNote call xolox#notes#delete(<q-bang>)
command! -bar -bang -nargs=1 SearchNotes call xolox#notes#search(<q-bang>, <q-args>)
command! -bar -bang RelatedNotes call xolox#notes#related(<q-bang>)
Please sign in to comment.
Something went wrong with that request. Please try again.