On Fri, Jan 29, 2010 at 12:22 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
Thanks, I did it! But still, how to send <CR> now? This is the function I'm trying to implement:
function! RunProject(...)
if !exists("s:project_command") || s:project_command=="" || (a:0==1 && a:1=="alter")
let s:project_command=expand("%:p")
return ':!'.s:project_command
else
return ':!'.s:project_command<CR>
endif
endfunction
map <expr> <F12> RunProject()
map <expr> <C-F12> RunProject("alter")
When working on simple scripts which can be run as is, I simple press F12 then enter to run, there is nothing to add. For other binary executable projects usually that binary is in the same directory or somewhere around, luckily it maybe even called the same as buffer name, again I use F12 and edit the command a little to point to actual binary and press enter. Next time I don't need to press enter, command is defined so just F12 is enough. If I still want to alter the command, I press Ctrl+F12 and edit the line. Unfortunately I can't figure out how to sent <CR> withing the returned value. I get "E121: Undefined variable: CR".
--
Aarto
-- Try using an expression mapping to call your function, which should
just return the incomplete command line with the leading : but without
the trailing <CR>.
:help map-<expr>
Thanks, I did it! But still, how to send <CR> now? This is the function I'm trying to implement:
function! RunProject(...)
if !exists("s:project_command") || s:project_command=="" || (a:0==1 && a:1=="alter")
let s:project_command=expand("%:p")
return ':!'.s:project_command
else
return ':!'.s:project_command<CR>
endif
endfunction
map <expr> <F12> RunProject()
map <expr> <C-F12> RunProject("alter")
When working on simple scripts which can be run as is, I simple press F12 then enter to run, there is nothing to add. For other binary executable projects usually that binary is in the same directory or somewhere around, luckily it maybe even called the same as buffer name, again I use F12 and edit the command a little to point to actual binary and press enter. Next time I don't need to press enter, command is defined so just F12 is enough. If I still want to alter the command, I press Ctrl+F12 and edit the line. Unfortunately I can't figure out how to sent <CR> withing the returned value. I get "E121: Undefined variable: CR".
--
Aarto
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment