Permalink
Browse files

New *** mapping to insert horizontal rulers

  • Loading branch information...
1 parent 6faa5d7 commit fabedb0dc5eec89fd3075c8cf314da443a27b818 @xolox committed Nov 25, 2011
Showing with 31 additions and 2 deletions.
  1. +2 −0 README.md
  2. +14 −1 autoload/xolox/notes.vim
  3. +5 −0 doc/notes.txt
  4. +5 −1 ftplugin/notes.vim
  5. +5 −0 plugin/notes.vim
View
@@ -66,6 +66,8 @@ If you don't want the plug-in to perform these substitutions, you can set this o
:let g:notes_smart_quotes = 0
+If you type the three characters `***` in insert mode in quick succession, a horizontal ruler delimited by empty lines will be inserted. This mapping cannot be disabled simply because it seems unlikely to me that someone would want to type this actual text.
+
### The `g:notes_shadowdir` option
The notes plug-in comes with some default notes containing documentation about the plug-in. This option defines the path of the directory containing these notes.
View
@@ -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.15.3'
+let g:xolox#notes#version = '0.15.4'
function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
@@ -733,6 +733,19 @@ endfunction
" Functions called by the file type plug-in and syntax script. {{{2
+function! xolox#notes#insert_ruler() " {{{3
+ let lnum = line('.')
+ if getline(lnum) =~ '\S' && getline(lnum + 1) !~ '\S'
+ let lnum += 1
+ endif
+ let line1 = prevnonblank(lnum)
+ let line2 = nextnonblank(lnum)
+ if line1 < lnum && line2 > lnum
+ execute printf('%i,%idelete', line1 + 1, line2 - 1)
+ endif
+ call append(line1, ['', g:notes_ruler_text, ''])
+endfunction
+
function! xolox#notes#insert_quote(style) " {{{3
" XXX When I pass the below string constants as arguments from the file type
" plug-in the resulting strings contain mojibake (UTF-8 interpreted as
View
@@ -147,6 +147,11 @@ option to zero like this:
>
:let g:notes_smart_quotes = 0
+If you type the three characters '***' in insert mode in quick succession, a
+horizontal ruler delimited by empty lines will be inserted. This mapping
+cannot be disabled simply because it seems unlikely to me that someone would
+want to type this actual text.
+
-------------------------------------------------------------------------------
The *g:notes_shadowdir* option
View
@@ -1,6 +1,6 @@
" Vim file type plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: November 15, 2011
+" Last Change: November 25, 2011
" URL: http://peterodding.com/code/vim/notes/
if exists('b:did_ftplugin')
@@ -87,6 +87,10 @@ if g:notes_smart_quotes
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
endif
+" Format three asterisks as a horizontal ruler. {{{1
+inoremap <buffer> *** <C-o>:call xolox#notes#insert_ruler()<CR>
+let b:undo_ftplugin .= ' | execute "iunmap <buffer> ***"'
+
" Indent list items using <Tab>. {{{1
imap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list('>>', line('.'), line('.'))<CR>
smap <buffer> <silent> <Tab> <C-o>:<C-u>call xolox#notes#indent_list('>>', line("'<"), line("'>"))<CR><C-o>gv
View
@@ -55,6 +55,11 @@ if !exists('g:notes_smart_quotes')
let g:notes_smart_quotes = 1
endif
+" Text used for horizontal rulers.
+if !exists('g:notes_ruler_text')
+ let g:notes_ruler_text = repeat(' ', ((&tw > 0 ? &tw : 79) - 5) / 2) . '* * *'
+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>, 'edit')

0 comments on commit fabedb0

Please sign in to comment.