Skip to content

Commit

Permalink
New "notes_smart_quotes" option to disable automatic substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 15, 2011
1 parent 1de0527 commit 3327d21
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 16 deletions.
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -28,10 +28,12 @@ Unzip the most recent [ZIP archive] [download] file inside your Vim profile dire

## 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'

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

All your notes are stored together in one directory. This option defines the path of this directory.
Expand All @@ -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.

### 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 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.
Expand Down
2 changes: 1 addition & 1 deletion autoload/xolox/notes.vim
Expand Up @@ -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.12.9'
let g:xolox#notes#version = '0.12.10'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down
28 changes: 27 additions & 1 deletion doc/notes.txt
Expand Up @@ -79,10 +79,13 @@ 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| by including a line like this:
configured in your |vimrc| script by including a line like this:
>
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

Expand Down Expand Up @@ -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
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

Expand Down
28 changes: 16 additions & 12 deletions ftplugin/notes.vim
Expand Up @@ -56,32 +56,36 @@ let b:undo_ftplugin .= ' | execute "iunmap <buffer> @"'
set completeopt+=longest

" 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> --
let b:undo_ftplugin .= ' | execute "iunmap <buffer> --"'
endif

" Change plain quotes to curly quotes as they're typed. {{{1
imap <buffer> <expr> ' xolox#notes#insert_quote(1)
imap <buffer> <expr> " xolox#notes#insert_quote(2)
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
if g:notes_smart_quotes
imap <buffer> <expr> ' xolox#notes#insert_quote(1)
imap <buffer> <expr> " xolox#notes#insert_quote(2)
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
endif

" 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> <-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ->"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <-"'
endif

" Convert ASCII list bullets to Unicode bullets. {{{1
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> -"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"'
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
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('*')
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
imap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list('>>', line('.'), line('.'))<CR>
Expand Down
7 changes: 6 additions & 1 deletion plugin/notes.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: October 18, 2011
" Last Change: November 15, 2011
" URL: http://peterodding.com/code/vim/notes/

" Support for automatic update using the GLVS plug-in.
Expand Down Expand Up @@ -50,6 +50,11 @@ if !exists('g:notes_title_sync')
let g:notes_title_sync = 'prompt'
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.
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>)
Expand Down

0 comments on commit 3327d21

Please sign in to comment.