Я недавно перешел с Eclipse на Vim. Я люблю это. Я работаю над несколькими зависаниями, но одна из тех, с которыми у меня много проблем, - это комментарии в документации PHP. В eclipse я мог бы ввести:
/** [enter]
, и следующая строка автоматически заполнилась бы
*
, так что я бы получил:
/**
* [comment goes here]
I ' Мне интересно, есть ли что-нибудь подобное для vim. Кажется, есть плагины для автоматического создания комментариев к документам с помощью команды, но мне бы хотелось, чтобы они выполнялись во время набора текста.
Я играл со сценарием отступа PHP ( http://www.vim.org/scripts/script.php?script_id=1120 ), и я заставил его распознавать, когда он находится внутри doc comment block, но я не могу понять, как заставить его на самом деле изменить текст и добавить "*" после нажатия клавиши Enter внутри блока.
Я пробовал то, что видел другие плагины:
let @z = ' * '
put! z
тоже попробовал:
exe 'normal!' '"zgp'
но безуспешно. Разве это невозможно из сценария отступа, и если нет, как мне на самом деле заставить Vim распознавать блок комментариев документа и действовать соответствующим образом, пока я печатаю?
Любая помощь будет принята с благодарностью! Учитывая эффективность и удобочитаемость кода, может ли кто-нибудь представить более краткое и эффективное решение для односвязного кругового списка?
#include
#include
struct node{
struct node* next;
int value;
};
struct list{
struct node* head;
};
struct node* init_node(int value){
struct node* pnode;
if (!(pnode = (struct node*)malloc(sizeof(struct node)))){
return NULL;
}
else{
pnode->value = value;
}
return pnode;
}
struct list* init_list(){
struct list* plist;
if (!(plist = (struct list*)malloc(sizeof(struct list)))){
return NULL;
}
plist->head = NULL;
return plist;
}
void remove_node(struct list*a plist, int value){
struct node* current, *temp;
current = plist->head;
if (!(current)) return;
if ( current->value == value ){
if (current==current->next){
plist->head = NULL;
free(current);
}
else {
temp = current;
do {
current = current->next;
} while (current->next != plist->head);
current->next = plist->head->next;
plist->head = current->next;
free(temp);
}
}
else {
do {
if (current->next->value == value){
temp = current->next;
current->next = current->next->next;
free(temp);
}
current = current->next;
} while (current != plist->head);
}
}
void print_node(struct node* pnode){
printf("%d %p %p\n", pnode->value, pnode, pnode->next);
}
void print_list(struct list* plist){
struct node * current = plist->head;
if (!(current)) return;
if (current == plist->head->next){
print_node(current);
}
else{
do {
print_node(current);
current = current->next;
} while (current != plist->head);
}
}
void add_node(struct node* pnode,struct list* plist){
struct node* current;
struct node* temp;
if (plist->head == NULL){
plist->head = pnode;
plist->head->next = pnode;
}
else {
current = plist->head;
if (current == plist->head->next){
plist->head->next = pnode;
pnode->next = plist->head;
}
else {
while(current->next!=plist->head)
current = current->next;
current->next = pnode;
pnode->next = plist->head;
}
}
}