Skip to content

A vim text objects for various C and C++ blocks with power of clang.

Notifications You must be signed in to change notification settings

libclang-vim/vim-textobj-clang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

Make text objects for various C and C++ blocks with power of clang

This vim plugin makes text objects for various C and C++ blocks, function, class, namespace, expression, statement and so on.

Dependencies

If you use neobundle.vim, you can install this plugin easily as below.

NeoBundleLazy 'rhysd/libclang-vim', {
            \ 'build' : {
            \       'windows' : 'echo "Please build manually"',
            \       'mac' : 'make',
            \       'unix' : 'make',
            \   }
            \ }

NeoBundleLazy 'rhysd/vim-textobj-clang', {
            \ 'depends' : ['kana/vim-textobj-user', 'rhysd/libclang-vim'],
            \ 'autoload' : {
            \       'mappings' : [['xo', 'a;'], ['xo', 'i;']]
            \   }
            \ }

Simple operator-pending mappings i; and a;

Operator-pending mappings i; and a; are available. i; selects the element under cursor. a; selects the most inner definition under cursor.

For example, see below code.

int main()
{
    return 0;
}

When the cursor is placed at return, i; selects return 0; and a; selects whole main() function. This is very simple example. Clang can parse more complicated source files like Boost libraries.

Screenshot:

screenshot

More complicated operator-pending mappings

If you set g:textobj_clang_more_mappings to 1, many operator-pending mappings are defined. As a default, mappings in a below table are defined. You can control the number of the mappings with g:textobj_clang_mapping_kinds.

Mapping Block
i;m select the most inner definition
i;c select class blocks
i;f select function blocks
i;e select an expression
i;s select an statement
i;p select an parameter and a template parameter
i;n select a namespace
i;u select an element under cursor
i;a select expression, statement, function, class or namespace

License

The MIT License (MIT)

Copyright (c) 2014 rhysd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

About

A vim text objects for various C and C++ blocks with power of clang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published