In Emacs, I can create functions in Lisp language and place them in .emacs file. Those function will become commands that can be called from the editor or bound to keys just like any other built-in command.
Is there a way to do that in VSCode?
Note: The custom commands need to be able to call other commands. Simply using a batch file and running it as a task will not work.
A few marketplace extensions may be of interest:
Script Commands by Marcel J. Kloubert
multi-command by ryuta46
However in general, you'll need to write an extension to do anything complex.
There's also a VS Code issue tracking support for built-in macros
There's Power Tools by e.GO:digital. It has support for custom commands and event triggers (ie. on file changed), among other things.
Related
I want to write a vscode extension and use vscode.commands.executeCommands(), but I don't know what parameters the command I want to use takes.
For example, when I want to use the "actions.find" command, how do I find out what parameters this specific API accepts?
I don't think there's any comprehensive documentation on commands and their arguments at this time. This page does list some of the most important ones though.
For some commands, there's also args auto-completion in keybindings.json:
Note that a lot of the built-in commands aren't much of an "API" at all. Looking at its implementation, "actions.find" in particular does not seem to support any arguments that would be useful to extensions. Compare this to the implementation of "workbench.action.findInFiles", which supports a well-defined set of arguments such as search query etc.
So I'm writing Python with IDLE and my usual workflow is to have two windows (an editor and a console), and run my script with F5 to quickly test it.
My script has some non-optional command line parameters, and I have two conflicting desires:
If someone launches my script without passing any parameters, I'd like him to get an error telling him to do so (argparse does this well)
When I hit F5 in IDLE, I'd like to have my script run with dummy parameters (and I don't want to have more keystrokes than F5 to have this work, and I don't want to have a piece of code I have to remember to remove when I'm not debugging any more)
So far my solution has been that if I get no parameters, I look for a params.debug file (that's not under source control), and if so, take that as default params, but it's a bit ugly... so would there be a cleaner, more "standard" solution to this? Do other IDEs offer easier ways of doing this?
Other solutions I can think of: environment variables, having a separate "launcher" script that's the one taking the "official" parameters.
(I'm likely to try out another IDE anyway)
With some editors you can define the 'execute' command,
For example with Geany, for Python files, F5 is python2.7 %f. That could be modified to something like python2.7 %f dummy parameters. But I use an attached terminal window and its line history more than F5 like commands.
I'm an Ipython user, so don't remember much about the IDLE configuration. In Ipython I usually use the %run magic, which is more like invoking the script from a shell than from an IDE. Ipython also has a better previous line history than the shell.
For larger scripts I like to put the guts of the code (classes, functions) in one file, and test code in the if __name__ block. The user interface is in another file that imports this core module.
Thanks for your question. I also searched for a way to do this. I found that Spyder which is the IDE I use has an option under Run/Configure to enter the command line parameters for running the program. You can even configure different ones for the different editors you have open.
Python tracker issue 5680 is a proposal to add to Idle a way to set command lines args for F5 Run module. You are free to test any of the proposed patches if you are able to apply them.
In the meanwhile conditionally extending sys.argv as done below should fulfill your requirements.
import sys
in __name__ == '__main__':
if 'idlelib.PyShell' in sys.modules:
sys.argv.extend(('a', '-2')) # add your argments here.
print(sys.argv) # in use, parse sys.argv after extending it
# ['C:\\Programs\\python34\\tem.py', 'a', '-2']
I want to know if there is a standardized way to declare your prefer diff tool (as for file or directory comparison).
For preferred editor there is the EDITOR environment variable, but I wasn't able to find one for diff.
If not maybe someone wrote a script that can reconfigure most used tools to do this.
EDITOR is usually used by various shells that provide line-editing functionality on certain things like your command history. For example, pressing v in vi-edit mode within bash will bring up the command for editing in your preferred editor.
I'm unaware of any aspects of the shell that do diff processing so the need for a DIFF variable seems unnecessary. If you want to diff some files, just use diff or your preferred one if not diff.
However, nothing is stopping you from writing a program of your own which does use a DIFF variable to perform difference analysis on files.
I have a problem with notepad++ macro.
I use notepad++ v.6.4.3 and I defined about 50-60 macro, but when i tried call some, notepad++ mess the macro or write only part of them.
Also...where notepad++ write the user's macro? I search in %appdata%/notepad++ folder, in shortcuts.xml, but I found nothing...I tried also in shortcuts.xml in program/notepad++ folder, but the results is similar.
Weel...How can I do?
I must export the macro that I created and notepad++ don't write random things...
Please help me
Thanks
Please consider
reporting the problem as suggested on Notepad++ homepage
switching to another form of macros. Although I strongly prefer AutoHotKey (because it works in all applications across Windows platform), other options work well, too.
One issue that tripped me up for a bit was caused by me trying to assign MY macro to a pre-existing key binding. Specifically, I recorded my macro, and then tried to assign it to Alt+1. However, Alt+1 was already bound to an intrinsic Notepad++ feature, so my macro never ran.
I hope this helps at least one person out there.
So I've been using Exuberant ctags with Emacs to navigate my way around a Linux kernel driver I'm trying to understand. I just spent a day debugging a problem which boiled down to me reading the wrong function definition, because foo() was defined (differently) in two separate files, and using M-. to navigate to the function definition took me to the irrelevant one of the two possible options. Is there a way to reliably navigate to a function definition in Emacs? I've given Vim a try with C-] and that seems to take me to the correct function definition, but I'm not normally a Vim user. So I'm looking for an Emacs specific solution, not a "switch from Emacs to Vim".