vim作为一个编辑利器一直是我的最爱,但是到目前为止,vim只有一点令我感到不爽,那就是他的粘贴复制。也许在这篇(文章)[http://www.aftermath.cn/2016/06/27/vim_tips/]中,已经简单地介绍了一下,今天,再把这个问题详细的介绍一下,以留下较深刻的印象。以下除非做特殊的说明,不然默认的操作都是在X11环境下进行的,所谓的X11就是Debian Ubuntu或者其他Unix系统默认的操作环境。与之对应的自然就是ssh(Xshell)什么的,这点需要注意。
vim可以拥有多达10个寄存器,当然每个寄存器都有自己的目的与作用。
每个寄存器可以使用单个双引号“ “ ”去展示, 比如,"r
就是r寄存器。假设在视图模式下,你选择一块文本,然后使用"r
+ y
,这个命令就是把你选择的文本暂存到r
寄存器中,使用"r
+ p
就可以把刚才复制的内存打印出来了。如果在一个文本中,这个命令就是y
和 p
的复杂版。
上面这个r寄存器是你自己可以命名的。
基本的命令格式就是 寄存器 加 动作。比如,想使用"0
寄存器的内容,可以键入"0
+ p
.
"0
保存最后一次yanked的内容,"1
保存最后一次删除或者修改的内容。The same way “1 holds the last delete, “2 holds the second last delete, “3 holds the third last, etc up to “9
".
保存最后一次插入模式的内容。
"%
打印正在编辑文本所在的path.
"#
:
":
命令: reg
就可以打印所有寄存器的内容。
ttps://stackoverflow.com/questions/1497958/how-do-i-use-vim-registers
Linux设备模型是一个很大的概念,这里就借着这篇(pdf)[https://bootlin.com/pub/conferences/2019/elce/opdenacker-kernel-programming-device-model/opdenacker-kernel-programming-device-model.pdf]稍微介绍一下。
主要的数据结构涉及三类: struct bus_type
,which was defined in include/linux/device.h
.这个结构体就是定义了设备的bus类型,包括USB、PCI、I2C等总线类型。
实例化这个结构体,就代表了其中的一种协议。
struct bus_type {
const char *name;
const char *dev_name;
struct device *dev_root;
const struct attribute_group **bus_groups;
const struct attribute_group **dev_groups;
const struct attribute_group **drv_groups;
int (*match)(struct device *dev, struct device_driver *drv);
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
int (*probe)(struct device *dev);
void (*sync_state)(struct device *dev);
int (*remove)(struct device *dev);
void (*shutdown)(struct device *dev);
int (*online)(struct device *dev);
int (*offline)(struct device *dev);
int (*suspend)(struct device *dev, pm_message_t state);
int (*resume)(struct device *dev);
int (*num_vf)(struct device *dev);
int (*dma_configure)(struct device *dev);
const struct dev_pm_ops *pm;
const struct iommu_ops *iommu_ops;
...
}
该结构体同样定义在上述头文件中,代表了在某一种总线上控制的一种特定设备。
struct device_driver {
const char *name;
struct bus_type *bus; //继承上面的一种类型
struct module *owner;
const char *mod_name; /* used for built-in modules */
bool suppress_bind_attrs; /* disables bind/unbind via sysfs */
enum probe_type probe_type;
const struct of_device_id *of_match_table;
const struct acpi_device_id *acpi_match_table;
int (*probe) (struct device *dev);
void (*sync_state)(struct device *dev);
int (*remove) (struct device *dev);
void (*shutdown) (struct device *dev);
int (*suspend) (struct device *dev, pm_message_t state);
int (*resume) (struct device *dev);
const struct attribute_group **groups;
const struct attribute_group **dev_groups;
const struct dev_pm_ops *pm;
void (*coredump) (struct device *dev);
struct driver_private *p;
};
该结构体同样在上述头文件中,代表了一个连接到总线的设备。根据内核的注释,这里有一个问题就是在linux的设备模型中,kobject代表了一个很重要的含义。
struct device {
struct kobject kobj;
struct device *parent;
struct device_private *p;
const char *init_name; /* initial name of the device */
const struct device_type *type;
struct bus_type *bus; /* type of bus device is on */
struct device_driver *driver; /* which driver has allocated this
device */
void *platform_data; /* Platform specific data, device
首先声明, 这个阶段的文章, 大部分是参考的网上的文章,所以, 侵权必删。
next[k]表示p[k]前面有相同前缀尾缀的长度(这个长度是按最大算的),p[next[k]]表示相同前缀的最后一个字符,如果p[next[k]]==p[k],则可以肯定next[k+1]=next[k]+1,如果p[next[k]]!=p[k],则思考,既然next[k]长度的前缀尾缀都不能匹配了,是不是应该缩短这个匹配的长度,到底缩短多少呢,next[next[k]]表示p[next[k]]前面有相同前缀尾缀的长度(这个长度是按最大算的),所以一直递推就可以了,因为这个缩小后的长度都是按最大的算的
static char p[] = "agctagcagctagct";
int main() {
int len = strlen(p);
int next[len + 1];
printf("len is %d\n", len);
next[0] = -1;
int j = 0, k = -1;
while(j <= len){
if (k == -1 || p[k] == p[j]){
k++; j++;
next[j] = k;
} else {
k = next[k];
}
}
int i = 0;
for (; i <= len; i++){
printf("%d ", next[i]);
}
printf("\n");
}
代码写的很乱,主要是记忆其中的一些关键细节。说白了, next[]的值就是当前 j 位置 前 子串的最长前后缀匹配的长度。第0号没有前缀,所以该next[]的数值设定为-1, 主要做的目的主要是为了编程的方便。
因为项目需要,需要下载risc-v的
因为学校的网络临时更改了策略(一个帐号只能登录一个终端,且只能无线),晕死, 真的不知道这么扯淡的决定是如何想出来的?!!难道一个庞大的学校的网络用户只有 那些傻甜白的用户在使用?这点特殊的需求就应该在业务处理的时候想到。
好在这个无线网络应该是具有很大的问题设计缺陷,缺陷之一就是你既然规定了一个帐号只能使用同一个终端,那么这个无线网络就不能共享,对不对?
好了,牢骚完了接着我们看看如何将这个网络共享。
首先,我这里接入无线的设备是台式win10,没有自带的无线网卡,买了一个tplink的无线网卡,非常便宜的。插入机箱后,按照无线接入网络的方式接入当地的无线网络就好。
打开网络设置管理->设置适配器->右击你上网的这个无线网卡-》属性->共享->internet连接共享-》选择你要分享的网络。因为我这里要和有线路由器进行共享,所以直接选择以太网就行。
设置完无线网卡的共享属性后,接着设置以太网的网络属性,这里需要注意下,问题大部分出现在这里。右击以太网->属性->ipv4->绑定ip->自动获取ip
IP: 192.168.137.1
netmask : 255.255.255.0
注意上面的IP,你可以任意设置,只要你理解其中的原理就可以。这个网址就是路由器wan口的那个地址,相当于一个静态ip.
使用另一台pc,有线无线都可以的,只要能够登陆上路由器的管理界面。在上网设置里面,WAN口类型为静态,ip地址为192.168.137.3。子网掩码为255.255.255.0,网关为192.168.1.137.1.DNS 我这里使用的是88.8.8.8,问题应该不大。关键是,ip和网关的设置。这里的ip设置为win10那里的同一个网段下就可以。
其他的设置就不必介绍了,和其他的没有区别。
有什么问题可以邮箱联系