Skip to content

Commit 3327d21

Browse files
committed
New "notes_smart_quotes" option to disable automatic substitution
1 parent 1de0527 commit 3327d21

File tree

5 files changed

+68
-16
lines changed

5 files changed

+68
-16
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ Unzip the most recent [ZIP archive] [download] file inside your Vim profile dire
2828

2929
## Options
3030

31-
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:
31+
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:
3232

3333
let g:notes_directory = '~/Documents/Notes'
3434

35+
Note that after changing an option in your [vimrc script] [vimrc] you have to restart Vim for the changes to take effect.
36+
3537
### The `g:notes_directory` option
3638

3739
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
4850

4951
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.
5052

53+
### The `g:notes_smart_quotes` option
54+
55+
By default the notes plug-in automatically performs several substitutions on the text you type in insert mode. Here are those substitutions:
56+
57+
* `'` becomes `` or `` depending on where you type it
58+
* `"` becomes `` or `` (same goes for these)
59+
* `--` becomes ``
60+
* `->` becomes ``
61+
* `<-` becomes ``
62+
* the bullets `*`, `+` and `-` become ``
63+
64+
If you don't want the plug-in to perform these substitutions, you can set this option to zero like this:
65+
66+
:let g:notes_smart_quotes = 0
67+
5168
### The `g:notes_shadowdir` option
5269

5370
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.

autoload/xolox/notes.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.12.9'
9+
let g:xolox#notes#version = '0.12.10'
1010

1111
function! xolox#notes#shortcut() " {{{1
1212
" The "note:" pseudo protocol is just a shortcut for the :Note command.

doc/notes.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ Options ~
7979
All options have reasonable defaults so if the plug-in works after
8080
installation you don't need to change any options. They're available for
8181
people who like to customize their directory layout. These options can be
82-
configured in your |vimrc| by including a line like this:
82+
configured in your |vimrc| script by including a line like this:
8383
>
8484
let g:notes_directory = '~/Documents/Notes'
8585
86+
Note that after changing an option in your |vimrc| script you have to restart
87+
Vim for the changes to take effect.
88+
8689
-------------------------------------------------------------------------------
8790
The *g:notes_directory* option
8891

@@ -115,6 +118,29 @@ disabled. If you set it to 'change_title' it will automatically change the
115118
title to match the filename. If you set it to 'rename_file' it will
116119
automatically rename the file on disk to match the title.
117120

121+
-------------------------------------------------------------------------------
122+
The *g:notes_smart_quotes* option
123+
124+
By default the notes plug-in automatically performs several substitutions on
125+
the text you type in insert mode. Here are those substitutions:
126+
127+
- ' becomes '‘' or '’' depending on where you type it
128+
129+
- '"' becomes '“' or '”' (same goes for these)
130+
131+
- '--' becomes '—'
132+
133+
- '->' becomes '->'
134+
135+
- '<-' becomes '←'
136+
137+
- the bullets '*', '+' and '-' become '•'
138+
139+
If you don't want the plug-in to perform these substitutions, you can set this
140+
option to zero like this:
141+
>
142+
:let g:notes_smart_quotes = 0
143+
118144
-------------------------------------------------------------------------------
119145
The *g:notes_shadowdir* option
120146

ftplugin/notes.vim

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,36 @@ let b:undo_ftplugin .= ' | execute "iunmap <buffer> @"'
5656
set completeopt+=longest
5757

5858
" Change double-dash to em-dash as it is typed. {{{1
59-
if xolox#notes#unicode_enabled()
59+
if g:notes_smart_quotes && xolox#notes#unicode_enabled()
6060
imap <buffer> --
6161
let b:undo_ftplugin .= ' | execute "iunmap <buffer> --"'
6262
endif
6363

6464
" Change plain quotes to curly quotes as they're typed. {{{1
65-
imap <buffer> <expr> ' xolox#notes#insert_quote(1)
66-
imap <buffer> <expr> " xolox#notes#insert_quote(2)
67-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
68-
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
65+
if g:notes_smart_quotes
66+
imap <buffer> <expr> ' xolox#notes#insert_quote(1)
67+
imap <buffer> <expr> " xolox#notes#insert_quote(2)
68+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ''"'
69+
let b:undo_ftplugin .= ' | execute ''iunmap <buffer> "'''
70+
endif
6971

7072
" Change ASCII style arrows to Unicode arrows. {{{1
71-
if xolox#notes#unicode_enabled()
73+
if g:notes_smart_quotes && xolox#notes#unicode_enabled()
7274
imap <buffer> ->
7375
imap <buffer> <-
7476
let b:undo_ftplugin .= ' | execute "iunmap <buffer> ->"'
7577
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <-"'
7678
endif
7779

7880
" Convert ASCII list bullets to Unicode bullets. {{{1
79-
imap <buffer> <expr> - xolox#notes#insert_bullet('-')
80-
imap <buffer> <expr> + xolox#notes#insert_bullet('+')
81-
imap <buffer> <expr> * xolox#notes#insert_bullet('*')
82-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> -"'
83-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"'
84-
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
81+
if g:notes_smart_quotes
82+
imap <buffer> <expr> - xolox#notes#insert_bullet('-')
83+
imap <buffer> <expr> + xolox#notes#insert_bullet('+')
84+
imap <buffer> <expr> * xolox#notes#insert_bullet('*')
85+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> -"'
86+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> +"'
87+
let b:undo_ftplugin .= ' | execute "iunmap <buffer> *"'
88+
endif
8589

8690
" Indent list items using <Tab>. {{{1
8791
imap <buffer> <silent> <Tab> <C-o>:call xolox#notes#indent_list('>>', line('.'), line('.'))<CR>

plugin/notes.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: October 18, 2011
3+
" Last Change: November 15, 2011
44
" URL: http://peterodding.com/code/vim/notes/
55

66
" Support for automatic update using the GLVS plug-in.
@@ -50,6 +50,11 @@ if !exists('g:notes_title_sync')
5050
let g:notes_title_sync = 'prompt'
5151
endif
5252

53+
" Smart quotes and such are enabled by default.
54+
if !exists('g:notes_smart_quotes')
55+
let g:notes_smart_quotes = 1
56+
endif
57+
5358
" User commands to create, delete and search notes.
5459
command! -bar -bang -nargs=? -complete=customlist,xolox#notes#cmd_complete Note call xolox#notes#edit(<q-bang>, <q-args>)
5560
command! -bar -bang -range NoteFromSelectedText call xolox#notes#from_selection(<q-bang>)

0 commit comments

Comments
 (0)