VIM as C++ IDE

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

VIM as C++ IDE

Peng Yu
Hi,

Currently, I use F12 to map to make command. However, the cursor will
jump to the file which contains the first error or the first warning.
It will leave the current file that I'm editing if it is different
from the file contain the errors or warnings. Another drawback, is
that the error message window should be gone before I can do any
editing in the source files.

map <F12> <ESC>:w<kEnter>:make<kEnter>

The plugin c.vim : C/C++-IDE
http://vim.sourceforge.net/scripts/script.php?script_id=213
seems very interesting. It is building "save and compile" command can
preserve the error window just like any other IDE (eclipse,
visual-studio). However, it can only compile single. My project is
rather complex and it is compiled by the make command.

Can some body provide some script to satisfy my more general
requirement? I want press <F12>, then make is called. The error window
will not be closed unless I do so. When I brower the error, the file
where the error is from will be open automatically and the cursor is
put in the error line?

Thanks,
Peng
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu
"Peng Yu" <[hidden email]> 写于 2006-10-14 05:59:29:

> Hi,
>
> Currently, I use F12 to map to make command. However, the cursor will
> jump to the file which contains the first error or the first warning.
> It will leave the current file that I'm editing if it is different
> from the file contain the errors or warnings. Another drawback, is
> that the error message window should be gone before I can do any
> editing in the source files.
>
> map <F12> <ESC>:w<kEnter>:make<kEnter>
>
> The plugin c.vim : C/C++-IDE
> http://vim.sourceforge.net/scripts/script.php?script_id=213
> seems very interesting. It is building "save and compile" command can
> preserve the error window just like any other IDE (eclipse,
> visual-studio). However, it can only compile single. My project is
> rather complex and it is compiled by the make command.
>
> Can some body provide some script to satisfy my more general
> requirement? I want press <F12>, then make is called. The error window
> will not be closed unless I do so. When I brower the error, the file
> where the error is from will be open automatically and the cursor is
> put in the error line?
>
> Thanks,
> Peng

Hi,

I know nothing about the "C++IDE plugin", but I bet what you need is the
'makeprg' option, see :h 'makeprg'

If you :set makeprg=/usr/bin/make

Chances are that your problem will solved.

However, if the "C++IDE" plugin are trying to use something other than
'makeprg', then IMO the plugin author should revise the script.

HTH.
--
Sincerely, Pan, Shi Zhu. ext: 2606

Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu
In reply to this post by Peng Yu
"Peng Yu" <[hidden email]> 写于 2006-10-14 05:59:29:

>
> map <F12> <ESC>:w<kEnter>:make<kEnter>
> Can some body provide some script to satisfy my more general
> requirement? I want press <F12>, then make is called. The error window
> will not be closed unless I do so. When I brower the error, the file
> where the error is from will be open automatically and the cursor is
> put in the error line?
>
> Thanks,
> Peng

for that simple, don't need any plugin:

map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>

You see, just add the :cope will do the trick.

Note that the cursor will be in :cope window then, you may need to press an
enter key to go into the first error. But what to do when there's no error?
then <CR> does nothing.

--
Sincerely, Pan, Shi Zhu. ext: 2606

Reply | Threaded
Open this post in threaded view
|

Re: [SPAM?]Re: VIM as C++ IDE

Robert Cussons
This is brilliant, I've never used make from inside Vim before, please
surpress your sniggers....As I am working on Linux with a microsoft
ergonomic keyboard, I have an unused windows button or two, how would I
map the right hand one to the same mapping as below, i.e. instead of
F12? As KDE's control centre in the custom shortcuts returns Win for the
windows button, I tried:
map <Win+M> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
but it doesn't seem to do anything, how does Vim interpret the windows key?

Many thanks,
Rob.

[hidden email] wrote:

> "Peng Yu" <[hidden email]> 写于 2006-10-14 05:59:29:
>
>>map <F12> <ESC>:w<kEnter>:make<kEnter>
>>Can some body provide some script to satisfy my more general
>>requirement? I want press <F12>, then make is called. The error window
>>will not be closed unless I do so. When I brower the error, the file
>>where the error is from will be open automatically and the cursor is
>>put in the error line?
>>
>>Thanks,
>>Peng
>
>
> for that simple, don't need any plugin:
>
> map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
>
> You see, just add the :cope will do the trick.
>
> Note that the cursor will be in :cope window then, you may need to press an
> enter key to go into the first error. But what to do when there's no error?
> then <CR> does nothing.
>
> --
> Sincerely, Pan, Shi Zhu. ext: 2606
>
>
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu

As far as I know Vim cannot recognize the <Win> key (Please correct me if
I'm wrong). In fact, it isn't that difficult to type all those, so I'd
refer to keep the :cope window on all the time, and I have the habit to
input :w everytime I changed a new line. So all I need to do is to type
:make, which isn't complex and I don't need a short-cut for that. Note that
you need to set your 'makeprg' right.

However, if all you need is to make use of the <Win> key, KDE can be set to
something like the "4-modifiers KDE default", and that's the settings I'm
currently using that and I use <win> shortcut key on most KDE-related
features.



--
Sincerely, Pan, Shi Zhu. ext: 2606


Robert Cussons <[hidden email]> 写于 2006-10-16 15:45:47:

> This is brilliant, I've never used make from inside Vim before, please
> surpress your sniggers....As I am working on Linux with a microsoft
> ergonomic keyboard, I have an unused windows button or two, how would I
> map the right hand one to the same mapping as below, i.e. instead of
> F12? As KDE's control centre in the custom shortcuts returns Win for the
> windows button, I tried:
> map <Win+M> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> but it doesn't seem to do anything, how does Vim interpret the windows
key?
>
> Many thanks,
> Rob.
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM?]Re: VIM as C++ IDE

Raimon Grau
In reply to this post by Robert Cussons
On 10/16/06, Robert Cussons <[hidden email]> wrote:
> This is brilliant, I've never used make from inside Vim before, please
> surpress your sniggers....As I am working on Linux with a microsoft
> ergonomic keyboard, I have an unused windows button or two, how would I
> map the right hand one to the same mapping as below, i.e. instead of
> F12? As KDE's control centre in the custom shortcuts returns Win for the
> windows button, I tried:
> map <Win+M> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> but it doesn't seem to do anything, how does Vim interpret the windows key?

You can map WinKey to Fx (where 12<x) , and then map Fx to whatever
wou want in vim.

xev will help you to find the keycode for winkey (usually 115 or 116)
then
xmodmap -e "keycode 115 = F30"
and you're done. Now windows key sends an F30 and you should be able
to make a map from vim

HTH,
  Ray


> Many thanks,
> Rob.
>
> [hidden email] wrote:
> > "Peng Yu" <[hidden email]> 写于 2006-10-14 05:59:29:
> >
> >>map <F12> <ESC>:w<kEnter>:make<kEnter>
> >>Can some body provide some script to satisfy my more general
> >>requirement? I want press <F12>, then make is called. The error window
> >>will not be closed unless I do so. When I brower the error, the file
> >>where the error is from will be open automatically and the cursor is
> >>put in the error line?
> >>
> >>Thanks,
> >>Peng
> >
> >
> > for that simple, don't need any plugin:
> >
> > map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> >
> > You see, just add the :cope will do the trick.
> >
> > Note that the cursor will be in :cope window then, you may need to press an
> > enter key to go into the first error. But what to do when there's no error?
> > then <CR> does nothing.
> >
> > --
> > Sincerely, Pan, Shi Zhu. ext: 2606
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

Robert Cussons
In reply to this post by panshizhu
[hidden email] wrote:
> As far as I know Vim cannot recognize the <Win> key (Please correct me if
> I'm wrong). In fact, it isn't that difficult to type all those, so I'd
> refer to keep the :cope window on all the time, and I have the habit to
> input :w everytime I changed a new line. So all I need to do is to type
> :make, which isn't complex and I don't need a short-cut for that. Note that
> you need to set your 'makeprg' right.

I agree with that, but how do I  keep the :cope window on all the time
set cope
in .vimrc or something?

>
> However, if all you need is to make use of the <Win> key, KDE can be set to
> something like the "4-modifiers KDE default", and that's the settings I'm
> currently using that and I use <win> shortcut key on most KDE-related
> features.

sorry, I don't really understande what you mean by this...although I've
just noticed that I have under KDE modifiers:

Modifier X11-Mod
Shift shift
Ctrl control
Alt mod1
Win mod4

I think I need to read up on what these KDE modifiers mean, anyway
thanks for the help with using make.

Rob.
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu
Robert Cussons <[hidden email]> 写于 2006-10-16 16:43:53:

> [hidden email] wrote:
> > As far as I know Vim cannot recognize the <Win> key (Please correct me
if
> > I'm wrong). In fact, it isn't that difficult to type all those, so I'd
> > refer to keep the :cope window on all the time, and I have the habit to
> > input :w everytime I changed a new line. So all I need to do is to type
> > :make, which isn't complex and I don't need a short-cut for that. Note
that
> > you need to set your 'makeprg' right.
>
> I agree with that, but how do I  keep the :cope window on all the time
> set cope
> in .vimrc or something?
just add a line
:cope 1
in .vimrc and it will be opened, if you want to keep it always open, uh,
just do never close it. ;-)

That's similiar to what I do, I personally using a modified project plugin,
and I wrote it in the startup script of the project, when the project
opens, the :cope window will open.


> sorry, I don't really understande what you mean by this...although I've
> just noticed that I have under KDE modifiers:
>
> Modifier   X11-Mod
> Shift      shift
> Ctrl      control
> Alt      mod1
> Win      mod4
I mean the tabpage left to the page you refered to. If you cannot get it,
well, just ignore it, doesn't matter too much ;-)

--
Sincerely, Pan, Shi Zhu. ext: 2606
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

Peng Yu
In reply to this post by panshizhu
On 10/15/06, [hidden email] <[hidden email]> wrote:

> "Peng Yu" <[hidden email]> 写于 2006-10-14 05:59:29:
> >
> > map <F12> <ESC>:w<kEnter>:make<kEnter>
> > Can some body provide some script to satisfy my more general
> > requirement? I want press <F12>, then make is called. The error window
> > will not be closed unless I do so. When I brower the error, the file
> > where the error is from will be open automatically and the cursor is
> > put in the error line?
> >
> > Thanks,
> > Peng
>
> for that simple, don't need any plugin:
>
> map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
>
> You see, just add the :cope will do the trick.
>
> Note that the cursor will be in :cope window then, you may need to press an
> enter key to go into the first error. But what to do when there's no error?
> then <CR> does nothing.

Is it possible to not to press the last enter key? It is not very convenient.

Thanks,
Peng
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu
"Peng Yu" <[hidden email]> 写于 2006-10-18 23:18:14:
> On 10/15/06, [hidden email] <[hidden email]> wrote:
> > for that simple, don't need any plugin:
> >
> > map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> >
> > You see, just add the :cope will do the trick.
> >
> > Note that the cursor will be in :cope window then, you may need to
press an
> > enter key to go into the first error. But what to do when there's no
error?
> > then <CR> does nothing.
>
> Is it possible to not to press the last enter key? It is not very
convenient.
>
> Thanks,
> Peng

try this instead:

map <F12> <ESC>:cope<kEnter><C-W>p:w<kEnter>:make<kEnter>

Hope that helps.
--
Sincerely, Pan, Shi Zhu. ext: 2606
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

Peng Yu
On 10/18/06, [hidden email] <[hidden email]> wrote:

> "Peng Yu" <[hidden email]> 写于 2006-10-18 23:18:14:
> > On 10/15/06, [hidden email] <[hidden email]> wrote:
> > > for that simple, don't need any plugin:
> > >
> > > map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> > >
> > > You see, just add the :cope will do the trick.
> > >
> > > Note that the cursor will be in :cope window then, you may need to
> press an
> > > enter key to go into the first error. But what to do when there's no
> error?
> > > then <CR> does nothing.
> >
> > Is it possible to not to press the last enter key? It is not very
> convenient.
> >
> > Thanks,
> > Peng
>
> try this instead:
>
> map <F12> <ESC>:cope<kEnter><C-W>p:w<kEnter>:make<kEnter>

I still have to type Enter at the end.
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

panshizhu
"Peng Yu" <[hidden email]> 写于 2006-10-19 10:17:55:

> On 10/18/06, [hidden email] <[hidden email]> wrote:
> > "Peng Yu" <[hidden email]> 写于 2006-10-18 23:18:14:
> > > Is it possible to not to press the last enter key? It is not very
> > convenient.
> > >
> > > Thanks,
> > > Peng
> >
> > try this instead:
> >
> > map <F12> <ESC>:cope<kEnter><C-W>p:w<kEnter>:make<kEnter>
>
> I still have to type Enter at the end.

I don't have the same problem as you, and the mapping works for me.

You'll have to be more specific and give more details, what did you see and
why you must press Enter, and what you have configured for you vim (.vimrc
might help).


--
Sincerely, Pan, Shi Zhu. ext: 2606
Reply | Threaded
Open this post in threaded view
|

Re: VIM as C++ IDE

Yegappan Lakshmanan
In reply to this post by panshizhu
Hi,

On 10/18/06, [hidden email] <[hidden email]> wrote:

> "Peng Yu" <[hidden email]> 写于 2006-10-18 23:18:14:
> > On 10/15/06, [hidden email] <[hidden email]> wrote:
> > > for that simple, don't need any plugin:
> > >
> > > map <F12> <ESC>:w<kEnter>:make<kEnter>:cope<kEnter>
> > >
> > > You see, just add the :cope will do the trick.
> > >
> > > Note that the cursor will be in :cope window then, you may need to
> press an
> > > enter key to go into the first error. But what to do when there's no
> error?
> > > then <CR> does nothing.
> >
> > Is it possible to not to press the last enter key? It is not very
> convenient.
> >
> > Thanks,
> > Peng
>
> try this instead:
>
> map <F12> <ESC>:cope<kEnter><C-W>p:w<kEnter>:make<kEnter>
>

You can also use the following map:

nnoremap <F12> :update<CR>:make<CR>:copen<CR>:wincmd p<CR>

- Yegappan