Hi Dominique and Luc,
thanks you for the advice. I agree that it is not a good idea to blindly replace everything. The most common case for me is probably static_cast so I would do that by default.
> In lh-cpp (*), I have 3 mappings that transform C casts into C++ casts -- and 6 more to cast an expression.
>
> This has to be done manually: you'll have to know if you want a const_cast, a static_cast, or a reinterpret_cast. As Dominique said, it can't really be done automatically. May be, clang could automate many things, but it won't be able to know whether you want to downcast with a dynamic_cast or with a static_cast?
>
> (*) https://github.com/LucHermitte/lh-cpp
>
Luc, I did install your library but the mapping provided ,,sc didn't do anything for me.
I did have an error when entering a c++ buffer after loading the plugin with VAM, something like:
line 39:
E227: mapping already exists for <80><fc>^D
I am not sure this is the reason I cannot use the mapping provided in your plugin.
I did write a function and mapping that for now should suit my needs:
function! ToStatic1()
" (type) b -> static_cast<type>(b)
" it is assumed cursor is inside the first cast
let original_keyword = &iskeyword
setlocal iskeyword +=_
setlocal iskeyword +=[
setlocal iskeyword +=]
setlocal iskeyword +=:
normal di(
let @a = @"
normal da(
normal istatic_cast<>
normal h
normal "ap
normal f>l
while 1
"get current char
let c = getline('.')[col('.')-1]
if c == ' '
normal x
else
break
endif
endwhile
echom c
if c != '('
normal i(
normal e
normal a)
endif
let &iskeyword=original_keyword
endfunction
nnoremap <silent> ,a :call ToStatic1()<CR>
Thanks,
Jorge
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Saturday, February 27, 2016
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment