LucHermitte / lh-brackets

LH's bracketing system for vim
Other
51 stars 2 forks source link

Brackets command not available in vimrc #7

Closed pnth closed 8 years ago

pnth commented 8 years ago

I added the following line in my vimrc as instructed in the home page

:Brackets < > -open=function('lh#cpp#brackets#lt') -visual=1 -nl

but it generated the following error when I opened vim

E492: Not an editor command: :Brackets < > -open=function('lh#cpp#brackets#lt') -visual=1 -nl

Running the same command after opening vim works

The reason why I added it is that I could not type > in my markdown page. It keeps jumping to find the next > character

The command :imap > Enter shows

 i  >           *@lh#brackets#closer(">",function('lh#html#brackets#gt'),"")

Also, could you please advise why I could not get the following mappings work (no bracket around the current word is deleted, or changed for the other commands)

noremap        ,bx         <Plug>DeleteBrackets
noremap        ,b<del>     <Plug>DeleteBrackets
noremap        ,b(         <Plug>ChangeToRoundBrackets
noremap        ,b[         <Plug>ChangeToSquareBrackets
noremap        ,b{         <Plug>ChangeToCurlyBrackets
noremap        ,b<         <Plug>ChangeToAngleBrackets
noremap        ,b\         <Plug>ToggleBackslash

The command :map ,bx Enter shows

,bx         * <Plug>DeleteBrackets

which shows the mapping is correct

Many thanks

LucHermitte commented 8 years ago

In your vimrc, you have first to be sure that the plugin has been loaded by your plugin manager. Then, the command :Brackets should be available.

You're right about > behaviour for markdown, I'll see to fix it.

Regarding :noremap ,bx <Plug>DeleteBrackets, it cannot work, you have to use nmap without the nore part. Anyway, you'll have to use something like:

let g:cb_want_mode = 0
map        ,bx         <Plug>DeleteBrackets
map        ,b<del>     <Plug>DeleteBrackets
map        ,b(         <Plug>ChangeToRoundBrackets
map        ,b[         <Plug>ChangeToSquareBrackets
map        ,b{         <Plug>ChangeToCurlyBrackets
map        ,b<         <Plug>ChangeToAngleBrackets
map        ,b\         <Plug>ToggleBackslash

And this time, this has to be done before lh-brackets is loaded with your plugin manager.

I have to fix the documentation on this topic, and have the <Plug> mapping always defined.

LucHermitte commented 8 years ago

You should not need to add :Bracket in your vimrc now. However, if you which for < and > behave as in C++, you should do it in $HOME/.vim/markdown/your_brackets.vim -- and don't bang :Bracket call, you don't want the definition global.

If you want the definition global, there you have to use :Bracket! from your .vimrc, after lh-brackets has been loaded by your plugin manager.

pnth commented 8 years ago

Thanks a lot for your fix and information. I will wait for when the mapping always defined since I do not know how to define the mapping before lh-brackets is loaded. I use junegunn/vim-plug.

LucHermitte commented 8 years ago

In your .vimrc, you certainly have added a line that starts vim-plug. Overriding <plug> mappings, setting the global leader key, ... all shall be done there.

According to vim-plug web site, I suspect the line before which you need to tune your plugins is: call plug#begin('~/.vim/plugged').