vim-textobj-quote


Ⅰ. 插件描述

DEPRECATED, please use vim-textobj-quote

Ⅱ. 基本信息

创建日期:  2013-12-24
使用用户:  2
Github星:  16
插件作者:  Reed Esau

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'reedes/vim-quotable'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'reedes/vim-quotable'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'reedes/vim-quotable'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/reedes/vim-quotable

Ⅳ. 文档说明

      • -
  • vim-quotable

    “Extending Vim to better support typographic (‘curly’) quote characters.”

    While Vim is renown for its text manipulation capabilities, it nevertheless
    retains a bias towards ASCII that stretches back to its vi roots on Unix. This
    can limit Vim’s appeal for those who prefer typographic characters like “curly
    quotes” over ASCII "straight quotes" in the prose and documentation they write.

    Features of this plugin:

    • Automatic entry of ‘typographic quotes’ from the 'straight quote' keys
    • Motion support for typographic quote pairs
    • Matchit % matching for typographic quote pairs
    • User can define alternative typographic quote pairs
    • Replace quotes in existing text, including entire buffer
    • Support for the [vim-surround][] plugin

    Requirements

    Requires a recent version of Vim compiled with Unicode support.

    Installation

    Install using Pathogen, Vundle, Neobundle, or your favorite Vim package
    manager.

    Strongly recommended - To support typographic quotes as text objects, the
    following dependency should be installed.

    Configuration

    Because you won't want typographic quotes in your code, the behavior of this
    plugin can be configured per file type. For example, to enable typographic
    quote support in markdown and textile files, place in your .vimrc:

    " standard vim command to enable loading the plugin files 
    " (and their indent support) for specific file types.
    " It may already be in your .vimrc!
    filetype plugin indent on
    
    augroup quotable
      autocmd!
      autocmd FileType markdown call quotable#init()
      autocmd FileType textile call quotable#init()
      autocmd FileType python call quotable#init({ 'educate': 0 })
    augroup END

    The last statement initializes the plugin for buffers of python file type, but
    disables the ‘educate’ feature by default. More on that below.

    Educating straight quotes

    This plugin will ‘educate’ quotes, meaning that it will dynamically transform
    straight quote key presses (" or ') into corresponding typographic quote
    characters.

    For example, entering the following sentence without this plugin using the
    straight quote keys:

    "It's Dr. Evil. I didn't spend six years in Evil Medical School to be called 'mister,'
    thank you very much."

    As expected all the quotes are straight ones. But with this plugin, the
    straight quotes are transformed into the typographic equivalent as you
    type:

    “It’s Dr. Evil. I didn’t spend six years in Evil Medical School to be called ‘mister,’
    thank you very much.”

    Entering straight quotes

    In some cases, straight (ASCII) quotes are needed, such as:

    “print "Hello World!"” is a simple program you can write in Python.

    To insert a straight quote while educating, enter «Ctrl-V» before the quote key:

    • «Ctrl-V» " - straight double quote
    • «Ctrl-V» ' - straight single quote

    Note that for units of measurement you’ll want to use the prime symbol rather
    than straight quotes, as in:

    Standing at 7′3″ (2.21 m), Hasheem Thabeet of the Oklahoma City Thunder is the tallest
    player in the NBA.

    Commands

    You can enable (or toggle) the educating behavior with the following
    commands:

    QuotableEducateOn
    QuotableEducateOff
    QuotableEducateToggle

    QuotableEducateOn will map the quote keys for transformation. Or better yet,
    map to keys via your .vimrc:

    nmap <silent> <leader>q1 :QuotableEducateOn<cr>
    nmap <silent> <leader>q0 :QuotableEducateOff<cr>
    nmap <silent> <leader>qq :QuotableEducateToggle<cr>

    Motion commands

    Motion commands are a powerful feature of Vim.

    By default, for motion commands, q denotes “double” quotes and Q denotes
    ‘single’ quotes.

    • ciq - [Change Inside “double” quotes] - excludes quote chars
    • ciQ - [Change Inside ‘single’ quotes] - excludes quote chars
    • caq - [Change Around “double” quotes] - includes quote chars
    • caQ - [Change Around ‘single’ quotes] - includes quote chars

    Apart from c for change, you can v for visual selection, d for deletion,
    y for yanking to clipboard, etc.

    _Quotable_’s motion command is smart too, able to distinguish between an
    apostrophe and single closing quote, even though both are represented by
    the same glyph. For example, try out viQ on the following sentence:

    ‘Really, I’d rather not relive the ’70s,’ said zombie Elvis.

    If you don’t like the defaults, you can redefine these by adding the following
    to your .vimrc, changing the motion characters as you desire:

    let g:quotable#doubleMotion = 'q'
    let g:quotable#singleMotion = 'Q'

    Matchit support

    Matchit enables jumping to matching quotes.

    • % - jump to the matching typographic (curly) quote character

    Replace support

    You can replace straight quotes in existing text with curly quotes, and
    visa versa. Add key mappings of your choice to your .vimrc:

    map <silent> <leader>qc <Plug>QuotableReplaceWithCurly
    map <silent> <leader>qs <Plug>QuotableReplaceWithStraight

    Both Normal and Visual modes are supported by this feature.

    To transform all quotes in a document, use Visual mode to select all the
    text in the document.

    Surround support

    This plugin supports basic surround capabilities. Add to your .vimrc key
    mappings of your choice:

    " NOTE: be sure to remove these mappings if using the tpope/vim-surround plugin!
    map <silent> Sq <Plug>QuotableSurroundDouble
    map <silent> SQ <Plug>QuotableSurroundSingle

    Then you can use motion commands to surround your text with quotes:

    (an asterisk is used to denote the cursor position)

    • visSq - My senten*ce. => “My sentence.”
    • visSQ - My senten*ce. => ‘My sentence.’

    Alternatively, if you’ve installed Tim Pope’s [vim-surround][] plugin you also
    have replace abilities on pairs of characters:

    • cs'q - 'Hello W*orld' => “Hello World”
    • cs"q - "Hello W*orld" => “Hello World”
    • cs(q - (Hello W*orld) => “Hello World”
    • cs(Q - (Hello W*orld) => ‘Hello World’

    Entering special characters

    Sometimes you must enter special characters (like typographic quotes)
    manually, such as in a search expression. You can do so through Vim’s digraphs
    or via your operating system’s keyboard shortcuts.

    GlyphVim DigraphOS XDescription
    ‘'6Opt-]left single quotation mark
    ’'9Shift-Opt-]right single quotation mark
    “"6Opt-[left double quotation mark
    ”"9Shift-Opt-[right double quotation mark
    ‚.9 single low-9 quote
    „:9Shift-Opt-wdouble low-9 quote
    ‹1<Opt-\left pointing single quotation mark
    ›1>Shift-Opt-\right pointing single quotation mark
    «<<Opt-\left pointing double quotation mark
    »>>Shift-Opt-\right pointing double quotation mark
    ′1' single prime
    ″2' double prime
    –-NOpt-hyphenen dash
    —-MShift-Opt-hyphenem dash
    …..Opt-;horizontal ellipsis
     NS non-breaking space
    ïi:Opt-U ilowercase i, umlaut
    æaeOpt-'lowercase ae

    For example, to enter left double quotation mark “, precede the digraph code
    "6 with Ctrl-K, like

    • «Ctrl-K» "6

    Alternatively, if you’re on OS X, you can use Opt-[ to enter this
    character.

    For more details, see:

    • :help digraphs

    International support

    Many international keyboards feature keys to allow you to input
    typographic quote characters directly. In such cases, you won’t need
    to change the behavior of the straight quote keys.

    But if you do, a standard convention is used by default:

    let g:quotable#doubleDefault = '“”'     " “double”
    let g:quotable#singleDefault = '‘’'     " ‘single’

    Those users editing most of their prose in German may want to change their
    defaults to:

    let g:quotable#doubleDefault = '„“'     " „doppel“
    let g:quotable#singleDefault = '‚‘'     " ‚einzel‘

    International users who desire maximum control can switch between quote
    pairings within a single buffer, adding the following key mappings to
    their .vimrc:

    nnoremap <silent> <leader>qd :call quotable#init()<cr>    " forces defaults
    nnoremap <silent> <leader>qn :call quotable#init({ 'double':'“”', 'single':'‘’' })<cr>
    nnoremap <silent> <leader>qg :call quotable#init({ 'double':'„“', 'single':'‚‘' })<cr>
    nnoremap <silent> <leader>qx :call quotable#init({ 'double':'„”', 'single':'‚’' })<cr>
    nnoremap <silent> <leader>qf :call quotable#init({ 'double':'«»', 'single':'‹›' })<cr>

    See also

    If you find this plugin useful, you may want to check out these others by
    @reedes:

    Future development

    If you’ve spotted a problem or have an idea on improving this plugin,
    please post it to the github project issue page.

    <!-- vim: set tw=74 :-->

    添加新评论