Is it possible two add delay time between execution of commands while using macros, it's like doing the macro in a slow motion... something like macro_dala = 200ms ...if this is not possible, what about adding a delay command while recording..
It depends from content of macro but in general you cannot achieve that unless you create a tool for us that can parse successfully all vim commands (and why not including mappings, plugins and ... :) just think about it for a while).
In case you insist and want to use it for SIMPLE & KNOWN commands, you can make it work by programming a function that will read the register where you hold your macro and then separate each command. After that, make a delay after each execution.
Related
I am running a class that takes several minutes. There are many times that it is about halfway done when I realize that I would like to print something. Is there a way to add in a print statement without having to stop the run and add it in if the specific function has not run yet? All I have really been able to find is sleep statements, but those would need to have been added before the run and I can't edit the code using a sleep timer.
You cannot pause the execution of the code and overwrite the code to reflect the changes in the forthcoming execution steps. The python file is compiled into a .pyc file which is currently getting executed. Hence even if you manage to pause it somehow, the current execution will resume the execution of the previous executable itself. also the use of sleep function is not actually stopping the execution. The code is still executing.
A good way to go about doing this is to setup logical breakpoints in your code rather than using multiple print statements throughout. You may have a look at this or this to know how to set break points. Although I would recommend using the VsCode debugger for the task.
Thus in conclusion, you cannot pause the script and make edits such that they reflect upon resuming the script's execution. Technically you can stall the execution of the script but that would never allow you to achieve what you intend to do.
The print statement is not your logger; use logging instead
Here are the docs: https://docs.python.org/3/library/logging.html
Here's a good example on how to use Logging: https://realpython.com/python-logging/
Start putting logger statements throughout your code.
a way to pause the code mid-run
Yes, it's called a breakpoint. You'll need to set a breakpoint somewhere in your code. It can even be a conditional breakpoint in that the breakpoint only triggers when a certain condition is met.
You can then look at the variable values in your program's stack.
PyCharm is very good at all of this. I highly recommend it.
I have a background task that needs to be run repeatedly, every hour or so, sending me an email whenever the task emitted non-trivial output.
I'm currently using cron for that, but it's somewhat ill-suited: it forces me to choose exact times at which the command is run, and it doesn't prevent overlap.
An alternative would be to run the script in a loop with sleep 3600 at the end of each iteration but this then needs extra work to make sure the script is always restarted after boot and such.
Ideally, I'd like a cron-like tool where I can give a set of commands to run repeatedly with approximate execution rates and the tool will run them "when convenient" and without overlapping execution of different iterations of a command (or even without overlapping execution of any command).
Short of writing such a tool myself, what would be the recommended approach?
I know that using job and channel in vim can run external procedures concurrently, but I want to concurrently run function which wrote by vimscript and in *.vim file.
How I can do it?
As far as I know, this is impossible.
At best you could start another vim process and run your function in this other process. The current instance won't be affected -- for instance it won't be possible to add thousand of keywords to highlight in the background.
I have some tasks in verilog file. And I want to see them in simvision when they are triggered.
Is there any way to find task's triggered point in simvision?
Is this can not be able to visualize in simvision? I know that manner like using print or display statements. But I need to visualize to simvision. Does anyone know that way?
UPDATE
Use a breakpoint
If you don't have access to the source of the task, or cannot modify it, >you could set a breakpoint when the task is called, execute some TCL >commands, then continue the simulation. The TCL commands could toggle a >signal or increment a counter. This could be automated with a small TCL >script. Depending on your situation, this could cause a performance hit on >the simulation time.
I want to know more this manner, would you let me know this way how to make it? Please let me know even if simple I am OK.
I don't think there is a native way to do this, but you should check the documentation that Cadence provides. That said, there are a few options you could employ to get information into the waveform.
Add a counter
If you can modify the source for the task, you can add a global counter somewhere which increments each time the task is called. Then add the counter register to the waveform.
Toggle a bit
Similarly, you could use a single bit and toggle it when the task is called. Using a counter has the advantage that if the task can be called twice in the same time step, you will see the counter increment by 2, whereas the single bit would toggle twice and not be visible in the waveform, unless you have zero-time event capturing enabled.
Use a breakpoint
If you don't have access to the source of the task, or cannot modify it, you could set a breakpoint when the task is called, execute some TCL commands, then continue the simulation. The TCL commands could toggle a signal or increment a counter. This could be automated with a small TCL script. Depending on your situation, this could cause a performance hit on the simulation time.
Recently I am using clang_complete to do C++ code completion. It is good and fast for small program but too slow for my case (I am working on large code base and usually one file takes several seconds to compile), even if I used libclang, which can cache some parsed results to speedup later parsing, if I understand correctly.
Currently clang_complete will block in ClangComplete until libclang finishes parsing. Even though it starts a worker thread, main thread still repeatedly checks if user pressed CTRLC or the worker thread completes successfully. During this period, vim becomes irresponsive and thus makes this plugin hard to use.
I want to make some improvement to this behavior, for example, ClangComplete will not block, but return empty results if it takes longer than 0.2 seconds, while the thread is still running. When libclang finishes its parsing, and it detects that I am still typing the same completion word, it will popup a completion menu.
The difficulties for this is:
how to popup a menu at that time, without causing some subtle race conditions between different threads,
how does it know whether I am still typing the same completion word? I think vim itself keep track of this, because when I type something wrong, for example, std::strang instead of std::string, then I type backspace to delete the wrong ang, the completion menu will show up again. So how do I access to this internal flag?
Vimscript is single-threaded; you won't have to worry about races.
Vim will pass the base (i.e. the part of the completion word already typed / completed) into your function. Check out :help complete-functions for details and an example.
In general, your approach (assuming you're using an embedded language like Python or Perl for the multi-threading) should be feasible; however, I haven't seen something like that attempted yet.