Permalink
Browse files

New "notes_smart_quotes" option to disable automatic substitution

  • Loading branch information...
xolox committed Nov 15, 2011
1 parent 1de0527 commit 3327d2159af5cb713fde50ffedd61a085c343b9b
Showing with 68 additions and 16 deletions.
  1. +18 −1 README.md
  2. +1 −1 autoload/xolox/notes.vim
  3. +27 −1 doc/notes.txt
  4. +16 −12 ftplugin/notes.vim
  5. +6 −1 plugin/notes.vim
View
@@ -28,10 +28,12 @@ Unzip the most recent [ZIP archive] [download] file inside your Vim profile dire
## Options ## Options
All options have reasonable defaults so if the plug-in works after installation you don't need to change any options. They're available for people who like to customize their directory layout. These options can be configured in your [vimrc] [vimrc] by including a line like this: All options have reasonable defaults so if the plug-in works after installation you don't need to change any options. They're available for people who like to customize their directory layout. These options can be configured in your [vimrc script] [vimrc] by including a line like this:
let g:notes_directory = '~/Documents/Notes' let g:notes_directory = '~/Documents/Notes'
Note that after changing an option in your [vimrc script] [vimrc] you have to restart Vim for the changes to take effect.
### The `g:notes_directory` option ### The `g:notes_directory` option
All your notes are stored together in one directory. This option defines the path of this directory. All your notes are stored together in one directory. This option defines the path of this directory.
@@ -48,6 +50,21 @@ When you rename a file in your notes directory but don't change the title, the p
If you set this option to the string `'no'` this feature will be completely disabled. If you set it to `'change_title'` it will automatically change the title to match the filename. If you set it to `'rename_file'` it will automatically rename the file on disk to match the title. If you set this option to the string `'no'` this feature will be completely disabled. If you set it to `'change_title'` it will automatically change the title to match the filename. If you set it to `'rename_file'` it will automatically rename the file on disk to match the title.
### The `g:notes_smart_quotes` option
By default the notes plug-in automatically performs several substitutions on the text you type in insert mode. Here are those substitutions:
* `'` becomes `‘` or `’` depending on where you type it
* `"` becomes `“` or `”` (same goes for these)
* `--` becomes `—`
* `->` becomes `→`
* `<-` becomes `←`
* the bullets `*`, `+` and `-` become `•`
If you don't want the plug-in to perform these substitutions, you can set this option to zero like this:
:let g:notes_smart_quotes = 0
### The `g:notes_shadowdir` option ### 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. 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 " Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently. " that Vim loads the script using the right encoding transparently.
let g:xolox#notes#version = '0.12.9' let g:xolox#notes#version = '0.12.10'
function! xolox#notes#shortcut() " {{{1 function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command. " The "note:" pseudo protocol is just a shortcut for the :Note command.
View
@@ -79,10 +79,13 @@ Options ~
All options have reasonable defaults so if the plug-in works after All options have reasonable defaults so if the plug-in works after
installation you don't need to change any options. They're available for installation you don't need to change any options. They're available for
people who like to customize their directory layout. These options can be people who like to customize their directory layout. These options can be
configured in your |vimrc| by including a line like this: configured in your |vimrc| script by including a line like this:
> >
let g:notes_directory = '~/Documents/Notes' let g:notes_directory = '~/Documents/Notes'
Note that after changing an option in your |vimrc| script you have to restart
Vim for the changes to take effect.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
The *g:notes_directory* option The *g:notes_directory* option
@@ -115,6 +118,29 @@ disabled. If you set it to 'change_title' it will automatically change the
title to match the filename. If you set it to 'rename_file' it will title to match the filename. If you set it to 'rename_file' it will
automatically rename the file on disk to match the title. automatically rename the file on disk to match the title.
-------------------------------------------------------------------------------
The *g:notes_smart_quotes* option
By default the notes plug-in automatically performs several substitutions on
the text you type in insert mode. Here are those substitutions:
- ' becomes '‘' or '’' depending on where you type it
- '"' becomes '“' or '”' (same goes for these)
- '--' becomes '—'
- '->' becomes '->'
- '<-' becomes '←'
- the bullets '*', '+' and '-' become '•'
If you don't want the plug-in to perform these substitutions, you can set this
option to zero like this:
>
:let g:notes_smart_quotes = 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
The *g:notes_shadowdir* option The *g:notes_shadowdir* option
View
@@ -56,32 +56,36 @@ let b:undo_ftplugin .= ' | execute "iunmap <buffer> @"'
set completeopt+=longest set completeopt+=longest
" Change double-dash to em-dash as it is typed. {{{1 " Change double-dash to em-dash as it is typed. {{{1
if xolox#notes#unicode_enabled() if g:notes_smart_quotes && xolox#notes#unicode_enabled()
imap <buffer> -- imap <buffer> --
let b:undo_ftplugin .= ' | execute "iunmap <buffer> --"' let b:undo_ftplugin .= ' | execute "iunmap <buffer> --"'
endif endif
" Change plain quotes to curly quotes as they're typed. {{{1 " Change plain quotes to curly quotes as they're typed. {{{1
imap <buffer> <expr> ' xolox#notes#insert_quote(1) if g:notes_smart_quotes
imap <buffer> <expr> " xolox#notes#insert_quote(2) imap <buffer> <expr> ' xolox#notes#insert_quote(1)
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"' imap <buffer> <expr> " xolox#notes#insert_quote(2)
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "''' let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
endif
" Change ASCII style arrows to Unicode arrows. {{{1 " Change ASCII style arrows to Unicode arrows. {{{1
if xolox#notes#unicode_enabled() if g:notes_smart_quotes && xolox#notes#unicode_enabled()
imap <buffer> -> → imap <buffer> -> →
imap <buffer> <- imap <buffer> <-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ->"' let b:undo_ftplugin .= ' | execute "iunmap <buffer> ->"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <-"' let b:undo_ftplugin .= ' | execute "iunmap <buffer> <-"'
endif endif
" Convert ASCII list bullets to Unicode bullets. {{{1 " Convert ASCII list bullets to Unicode bullets. {{{1
imap <buffer> <expr> - xolox#notes#insert_bullet('-') if g:notes_smart_quotes
imap <buffer> <expr> + xolox#notes#insert_bullet('+') imap <buffer> <expr> - xolox#notes#insert_bullet('-')
imap <buffer> <expr> * xolox#notes#insert_bullet('*') imap <buffer> <expr> + xolox#notes#insert_bullet('+')
let b:undo_ftplugin .= ' | execute "iunmap <buffer> -"' imap <buffer> <expr> * xolox#notes#insert_bullet('*')
let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"' let b:undo_ftplugin .= ' | execute "iunmap <buffer> -"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"' let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
endif
" Indent list items using <Tab>. {{{1 " Indent list items using <Tab>. {{{1
imap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list('>>', line('.'), line('.'))<CR> imap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list('>>', line('.'), line('.'))<CR>
View
@@ -1,6 +1,6 @@
" Vim plug-in " Vim plug-in
" Author: Peter Odding <peter@peterodding.com> " Author: Peter Odding <peter@peterodding.com>
" Last Change: October 18, 2011 " Last Change: November 15, 2011
" URL: http://peterodding.com/code/vim/notes/ " URL: http://peterodding.com/code/vim/notes/
" Support for automatic update using the GLVS plug-in. " Support for automatic update using the GLVS plug-in.
@@ -50,6 +50,11 @@ if !exists('g:notes_title_sync')
let g:notes_title_sync = 'prompt' let g:notes_title_sync = 'prompt'
endif endif
" Smart quotes and such are enabled by default.
if !exists('g:notes_smart_quotes')
let g:notes_smart_quotes = 1
endif
" User commands to create, delete and search notes. " 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 -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>)

0 comments on commit 3327d21

Please sign in to comment.