Home

Awesome

lh-cpp Build Status Project Stats

Features

lh-cpp is an heterogeneous suite of helpers for C and C++ programming.

It provides the following things:

An exhaustive list of all options is also available. For help using this plugin for the first time, please take a look at :h lh-cpp-first-steps

Text insertion facilities

Brackets

The insertion of pair of brackets-like characters is eased thanks to lh-brackets.

In modeINSERTVISUALNORMAL
keysExpands into ..Surrounds the selection with ... <sup>2</sup>Surrounds the current ...
((<cursor>)«»(<selection>)word
[[<cursor>]«»<sup>1</sup><sup>1</sup>
[ after a [[[<cursor>]]«»n/an/a
] before ]]close all ]]n/an/a
<localleader>[[<selection>]word
{{<cursor>}«»<sup>3</sup>{<selection>}word
<localleader>{{\n<selection>\n}«»line
<<<cursor>>«» after #include, or template on the same line
" (1 double quote)"<cursor>"«»<sup>1</sup><sup>1</sup>
"""<selection>"word
''<cursor>'«»<sup>1</sup><sup>1</sup>
'' (2 single quotes)'<selection>'word
;closes all parenthesis after the cursor -- if there is nothing else
Notes:

Code snippets

INSERT-mode snippets abbreviations

There exist, over the WWW, a lot of configurations and mappings regarding C programming. Once again you will find shortcuts for if, else, elif (I know it is not a C keyword, but else if are), for, while, do, switch, and main. In C++, snippets are also provided for try, catch, and namespace. What is unique is the fact that when you type if in insert mode, it will automatically expand into ...

if () {
}

... in respect of the context. I.e.: within comments or strings (delimited by single or double quotes) if is not expanded. If keyword characters precede the typing, if is not expanded as well. Thus variables like tarif can be used without getting any headache.

Most of these same snippets, and a few variations, are also provided as template-files for mu-template. This time, you just need to type the first letters of the snippet/template name, and trigger the expansion (with <c-r><tab> by default). If several snippets match (like c/for, c/fori, cpp/fori and cpp/for-iterator when you try to expand fo), mu-template will ask you to choose which (matching) snippet you want to expand.

Instruction surrounding mappings

In visual mode, ,if wraps the selection within the curly brackets and inserts if () just before. In normal mode ,if does the same thing under the consideration that the selection is considered to be the current line under the cursor. Actually, it is not ,if but <LocalLeader>if, with maplocalleader assigned by default to the coma ,.

Expression-condition surrounding mappings

In the same idea, <LocalLeader><LocalLeader>if surrounds the selection with if ( and ) {\n«»\n}«».

Other notes

All the three mode oriented mappings respect and force the indentation regarding the current setting and what was typed.

More precisely, regarding the value of the buffer relative option b:usemarks (cf. lh-brackets), if could be expanded into:

if () {
    «»
}«»

The exact style (Alman, Stroustroup, ...) regarding whether brackets are on a new line, or not, can be tuned thanks to lh-dev :AddStyle feature.

Miscellaneous shortcuts

Note: in all the following mappings, , is actually the localleader that lh-cpp sets to the comma characcter if it isn't set already.

Templates

I'll try to maintain an up-to-date documentation of the snippets as most of them have options.

Wizards and other high-level features

Syntax highlighting

Miscellaneous

Installation

ActivateAddons lh-cpp
flavor 'LucHermitte/lh-cpp'
git clone git@github.com:LucHermitte/lh-vim-lib.git
git clone git@github.com:LucHermitte/lh-style.git
git clone git@github.com:LucHermitte/lh-tags.git
git clone git@github.com:LucHermitte/lh-dev.git
git clone git@github.com:LucHermitte/lh-brackets.git
git clone git@github.com:LucHermitte/searchInRuntime.git
git clone git@github.com:LucHermitte/mu-template.git
git clone git@github.com:tomtom/stakeholders_vim.git
git clone git@github.com:LucHermitte/alternate-lite.git
git clone git@github.com:LucHermitte/lh-cpp.git
Bundle 'LucHermitte/lh-vim-lib'
Bundle 'LucHermitte/lh-style'
Bundle 'LucHermitte/lh-tags'
Bundle 'LucHermitte/lh-dev'
Bundle 'LucHermitte/lh-brackets'
Bundle 'LucHermitte/searchInRuntime'
Bundle 'LucHermitte/mu-template'
Bundle 'tomtom/stakeholders_vim'
Bundle 'LucHermitte/alternate-lite'
Bundle 'LucHermitte/lh-cpp'

Credits

Many people have to be credited:

License

See also