我是一个Vim新手.我想将当前缓冲区的内容发送到外部命令的stdin(比方说邮件).我的最终目的是设置一个快捷方式,以便从当前的Vim缓冲区快速发送电子邮件.我猜这应该是一个微不足道的东西,但我找不到一种方法将Vim缓冲区发送到外部命令.提前致谢.
这是示例文件:
somestuff...
all: thing otherthing
some other stuff
Run Code Online (Sandbox Code Playgroud)
我想要做的是添加到以这样开头的行all::
somestuff...
all: thing otherthing anotherthing
some other stuff
Run Code Online (Sandbox Code Playgroud) 我是vim的新手,还在探索它的一些功能.我有vimgrep的问题.我可以搜索vimgrep /define/ **这样的模式,以便找到并打开包含a的下一个文件define.但我还不知道如何转到与我的模式匹配的下一个文件/行.有什么指针吗?
我是C++的新手.我在设置标题时遇到问题.这是来自functions.h
extern void apply_surface(int, int, SDL_Surface *, SDL_Surface *,SDL_Rect *);
Run Code Online (Sandbox Code Playgroud)
这是functions.cpp的函数定义
void
apply_surface(int x, int y, SDL_Surface * source, SDL_Surface *
destination,SDL_Rect *clip = NULL)
{
...
}
Run Code Online (Sandbox Code Playgroud)
这就是我在main.cpp中使用它的方式
#include "functions.h"
int
main (int argc, char * argv[])
{
apply_surface(bla,bla,bla,bla); // 4 arguments, since last one is optional.
}
Run Code Online (Sandbox Code Playgroud)
但是,这不会编译,因为,main.cpp不知道last参数是可选的.我怎样才能做到这一点?
给定一段时间(例如一天,一周,一个月),是否可以列出此时修改或添加的所有文件?
我正试图在旅行中解决等效的二叉树运动.这就是我所做的;
package main
import "tour/tree"
import "fmt"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
Walk(t.Left, ch)
}
ch <- t.Value
if t.Right != nil {
Walk(t.Right, ch)
}
}
// Same determines whether the trees
// t1 and t2 contain the same values.
func Same(t1, t2 *tree.Tree) bool {
ch1 := make(chan int)
ch2 := make(chan …Run Code Online (Sandbox Code Playgroud) 我试图继承str对象,并添加几个方法.我的主要目的是学习如何做到这一点.我被困在哪里,我是否应该在元类中继承字符串,并使用该元或子类str直接创建我的类?
而且,我想我需要以__new__()某种方式实现,因为,我的自定义方法将修改我的字符串对象,并将返回新的mystr obj.
我的类的方法应该可以使用str方法完全链接,并且应该在自定义方法修改它时始终返回一个新的我的类实例.我希望能够做到这样的事情:
a = mystr("something")
b = a.lower().mycustommethod().myothercustommethod().capitalize()
issubclass(b,mystr) # True
Run Code Online (Sandbox Code Playgroud)
我希望拥有它拥有的所有能力str.例如,a = mystr("something")然后我想使用它,如a.capitalize().mycustommethod().lower()
我的理解是,我需要实施__new__().我想是这样的,因为,字符串方法可能会尝试创建新的str实例.所以,如果我覆盖__new__(),他们应该会返回我的自定义str类.但是,__init__()在这种情况下,我不知道如何将参数传递给我的自定义类的方法.我想我需要使用type()才能在__new__()方法中创建一个新实例吗?
在匹配电子邮件地址时,在我匹配之后yasar@webmail,我想要捕获一个或多个(\.\w+)(我正在做的事情有点复杂,这只是一个例子),我尝试添加(.\ w +)+,但是它只捕获最后一场比赛.例如,yasar@webmail.something.edu.tr匹配但仅包括部分.tr之后yasar@webmail,因此我丢失.something并.edu分组.我可以在Python正则表达式中执行此操作,还是首先建议匹配所有内容,然后再拆分子模式?
我正在读这个答案,并提到这个代码;
if (data[c] >= 128)
sum += data[c];
Run Code Online (Sandbox Code Playgroud)
可以用这个替换;
int t = (data[c] - 128) >> 31;
sum += ~t & data[c];
Run Code Online (Sandbox Code Playgroud)
我很难理解这一点.有人可以解释按位运算符如何实现if语句的作用吗?
我试过了;
void *malloc(unsigned int);
struct deneme {
const int a = 15;
const int b = 16;
};
int main(int argc, const char *argv[])
{
struct deneme *mydeneme = malloc(sizeof(struct deneme));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是编译器的错误:
gereksiz.c:3:17: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
Run Code Online (Sandbox Code Playgroud)
而且,这也是;
void *malloc(unsigned int);
struct deneme {
const int a;
const int b;
};
int main(int argc, const char *argv[])
{
struct deneme *mydeneme = malloc(sizeof(struct deneme));
mydeneme->a = 15;
mydeneme->b = 20; …Run Code Online (Sandbox Code Playgroud)