I'm tring to copy c = getchar()
to c! ^ =EOF
c! ^ =EOF
.
I tried shift+v & p
, the code will appear right above the line, not in the line.
What should I do?
#include <stdio.h>
main()
{
int c;
c = getchar()
while (c != EOF {
putchar(c);
}
}
#include <stdio.h>
main()
{
int c;
while (c = getchar()!= EOF) {
putchar(c);
}
}
When you yank the c = getchar()
line , the register is in linewise mode , so any pastes will also create a new line. My UnconditionalPaste plugin has mappings like gcp
that force eg a characterwise paste. With that, you can insert the line after the while(
statement, and have it stay in the same line.
But actually, you probably want to replace the c
after the while(
with the yanked text. For that, another of my plugins, the ReplaceWithRegister plugin comes handy. With it, you can either visually select the c
or address it through a motion l
, and use the plugin's gr
mapping to replace the covered text with the register contents (again, sticking to the same line, so you only have to deal with the superfluous indent).
I usually do this kind of work with operations in movements over the same line with f and F . So I would do:
:20
to go to the line of c = getchar()!= EOF
fcdf)
to put cursor in first c
letter and cut until next )
character.
:7
go to seventh line, and
f(p
to go to first (
character and paste.
c
, hit ^
. d$
. /c
, for example. vlp
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.