Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

:TabNoteFromSelectedText and \en, \sn, \tn mappings (:edit, :split, :…

…tabnew)
  • Loading branch information...
commit d43f9c78a942cf3f327192c400624937642d8a40 1 parent 5636ceb
@xolox authored
View
17 README.md
@@ -4,7 +4,7 @@ The notes.vim plug-in for the [Vim text editor] [vim] makes it easy to manage yo
* **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 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)
+ * 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] [write] and [:update] [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`)
* The `:Note` and `:DeleteNote` commands support tab completion of note titles
@@ -107,14 +107,15 @@ This command will fail when changes have been made to the current buffer, unless
### The `:NoteFromSelectedText` command
-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>
+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, that's because it's intended to be executed from a mapping. The default mapping for this command is `\en` (the backslash is actually the character defined by the [mapleader] [mapleader] variable).
### The `:SplitNoteFromSelectedText` command
-Same as `:NoteFromSelectedText` but opens the new note in a vertical split window.
+Same as `:NoteFromSelectedText` but opens the new note in a vertical split window. The default mapping for this command is `\sn`.
+
+### The `:TabNoteFromSelectedText` command
+
+Same as `:NoteFromSelectedText` but opens the new note in a new tab page. The default mapping for this command is `\tn`.
### The `:DeleteNote` command
@@ -192,6 +193,9 @@ The following key mappings are defined inside notes.
* `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 the syntax highlighting of notes
@@ -273,6 +277,7 @@ This software is licensed under the [MIT license] [mit].
[gf]: http://vimdoc.sourceforge.net/htmldoc/editing.html#gf
[highlight]: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:highlight
[levenshtein]: http://en.wikipedia.org/wiki/Levenshtein_distance
+[mapleader]: http://vimdoc.sourceforge.net/htmldoc/map.html#mapleader
[mit]: http://en.wikipedia.org/wiki/MIT_License
[modeline]: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
[python]: http://python.org/
View
4 autoload/xolox/notes.vim
@@ -1,12 +1,12 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 30, 2011
+" Last Change: December 1, 2011
" URL: http://peterodding.com/code/vim/notes/
" 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.16.13'
+let g:xolox#notes#version = '0.16.14'
let s:scriptdir = expand('<sfile>:p:h')
function! xolox#notes#init() " {{{1
View
28 doc/notes.txt
@@ -12,8 +12,8 @@ notes in Vim:
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 |:NoteFromSelectedText| command (the |:SplitNoteFromSelectedText|
- command opens the new note in a split window)
+ 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)
@@ -225,18 +225,22 @@ note title and nothing more.
The *:NoteFromSelectedText* command
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 note. The name of this command isn't very well suited to daily use, that's
+because it's intended to be executed from a mapping. The default mapping for
+this command is '\en' (the backslash is actually the character defined by the
+|mapleader| variable).
-------------------------------------------------------------------------------
The *:SplitNoteFromSelectedText* command
Same as |:NoteFromSelectedText| but opens the new note in a vertical split
-window.
+window. The default mapping for this command is '\sn'.
+
+-------------------------------------------------------------------------------
+The *:TabNoteFromSelectedText* command
+
+Same as |:NoteFromSelectedText| but opens the new note in a new tab page. The
+default mapping for this command is '\tn'.
-------------------------------------------------------------------------------
The *:DeleteNote* command
@@ -379,6 +383,12 @@ Insert mode mappings ~
- '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 the syntax highlighting of notes ~
View
14 ftplugin/notes.vim
@@ -1,6 +1,6 @@
" Vim file type plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 25, 2011
+" Last Change: December 1, 2011
" URL: http://peterodding.com/code/vim/notes/
if exists('b:did_ftplugin')
@@ -113,6 +113,18 @@ let b:undo_ftplugin .= ' | execute "sunmap <buffer> <A-Left>"'
" Automatically remove empty list items on Enter. {{{1
inoremap <buffer> <silent> <expr> <CR> xolox#notes#cleanup_list()
+let b:undo_ftplugin .= ' | execute "iunmap <buffer> <CR>"'
+
+" Shortcuts to create new notes from the selected text. {{{1
+
+vmap <buffer> <silent> <Leader>en :NoteFromSelectedText<CR>
+let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>en"'
+
+vmap <buffer> <silent> <Leader>sn :SplitNoteFromSelectedText<CR>
+let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>sn"'
+
+vmap <buffer> <silent> <Leader>tn :TabNoteFromSelectedText<CR>
+let b:undo_ftplugin .= ' | execute "vunmap <buffer> <Leader>tn"'
" }}}1
View
9 plugin/notes.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 26, 2011
+" Last Change: November 28, 2011
" URL: http://peterodding.com/code/vim/notes/
" Support for automatic update using the GLVS plug-in.
@@ -16,8 +16,6 @@ call xolox#notes#init()
" 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>, '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>)
@@ -25,6 +23,11 @@ command! -bar -bang -nargs=? RecentNotes call xolox#notes#recent(<q-bang>, <q-ar
command! -bar -count=1 ShowTaggedNotes call xolox#notes#tags#show_tags(<count>)
command! -bar IndexTaggedNotes call xolox#notes#tags#create_index()
+" TODO Generalize this so we have one command + modifiers (like :tab)?
+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 -range TabNoteFromSelectedText call xolox#notes#from_selection(<q-bang>, 'tabnew')
+
" Automatic commands to enable the :edit note:… shortcut and load the notes file type.
augroup PluginNotes
Please sign in to comment.
Something went wrong with that request. Please try again.