code-snippets

Format Eclipse code snippets for blog publishing?

你。 提交于 2019-12-12 14:23:35
问题 Visual Studio has a plugin that allows one to copy code from any editor (C#, HTML, XML) and then paste it with HTML formatting that preserves the syntax highlighting, etc. This is very handy for publishing code samples/examples to a wep page/blog. I have seen one old (2006?) plugin for java to html conversion, but are there any broader solutions similar to the Visual studio plugin. Really what I am looking for is a way to select and copy a syntax-colored block of text in Eclipse and paste it

Dynamic Rstudio Code Snippet

眉间皱痕 提交于 2019-12-12 13:15:42
问题 I tend to use a lot of line breaks in my code like the following: # Data ========================================================================= Where the entire comment is always 80 characters long (including the hashtag). What I would like to do is write a code snippet for Rstudio that will insert the hashtag, then a space, then allow the user to type out a series of words, then insert another space, and finally fill in a bunch of "=" until the 80 character limit is reached. I'm not

Over-ride Default Snippet Prefix in VS Code

ぐ巨炮叔叔 提交于 2019-12-12 09:27:30
问题 I am writing some JavaScript snippets for VS Code, and when I add the one for an event listener, there are a number of pre-defined prefix allocations relating to other pieces of code. I would like to use "ael" as the prefix prompt for this snippet, but that defaults to an alert command (this is particularly frustrating because the first 3 letters of alert are actually "ale"), anyway, is there a way of over-riding the default behaviour? In the code below if I change the prefix to "ttt", and

How to format the userId in Google Analytics script?

戏子无情 提交于 2019-12-12 03:39:29
问题 for my static HTML webside I embedded this recommended script code to every page of the side. <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-96597161-1', 'auto'); ga('send', 'pageview'); ga('set',

Generate method stub snippet: Alter signature to make access level public

六月ゝ 毕业季﹏ 提交于 2019-12-12 02:25:33
问题 By default, the "Extract method..." command of Visual Studio generates method stubs with the lowest possible access level, usually private . The relevant code snippet for it only references "signature", but how can I edit this signature? For reference, contents of C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Snippets\1033\Refactoring\MethodStub.snippet : <?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

How to write a multi-line description for user snippets in VS Code

穿精又带淫゛_ 提交于 2019-12-11 23:57:56
问题 I tried to create my own user snippet for pascal in VS Code. It worked fine and the multi-line descriptions I wrote were displayed correctly. But after a while, like a month, the descriptions with multiple lines aren't working anymore. The problem may be the code for the multi-line descriptions because descriptions with only one row still works and displays correct. However the multi-line descriptions aren't displayed correctly and get replaced with a {0} instead of the description I wrote.

Get R snippet to accept whitespace in inserted text

◇◆丶佛笑我妖孽 提交于 2019-12-11 23:44:08
问题 I am trying to write a snippet to allow me to quickly insert comment text using my standard format: #######################################><################### ## [date and time goes here] ------------------------------ ## [comment goes here, can span multiple ## lines] #######################################><################### This is what I've got so far: snippet comm `r paste0( "#######################################><###################\n## ", date(), " -------------------------------

What format use to store code snippets with cross-platform compatibility in mind

只愿长相守 提交于 2019-12-11 21:06:32
问题 Consider that there are different programming languages and different IDE. Some IDE is possible to use for many languages, almost all Text Editor possible use with any programming language. There also many operation systems. And we have code snippets. We want write it once, use it anywhere. We don't want to be bound to any language, tool or platform. What format use to store code snippets ? Personally at this moment I store all snippets as files in single folder located in Dropbox. Files have

Any way in visual studio to programmatically modify selected editor text while in editor? Code snippets? Macros?

↘锁芯ラ 提交于 2019-12-11 17:55:23
问题 I would like to be able to highlight a section of text and remove any ';' in the highlighted section. I've written a "surround with snippet" to encapsulate the highlighted text, but would also like to pragmatically modify that text and am unsure how. I use the "Snippet Designer" extension in visual studios for snippet creation. I would expect the highlighted text " RunMethod1(var1); " to be converted to ".Then(() => RunMethod1(var1) ) " ie without the semi-colon. 回答1: You can use the

Make a vscode snippet that can use a variable number of arguments

萝らか妹 提交于 2019-12-11 15:34:10
问题 I am new to VSCode. Thinking about code snippets, I looked around for a way to kind of script inside the snippet. I mean to do more than just fill or transform a variable. For example... This is a simple snippet. I am going to type rci for the class initializer. When I enter the method arguments I would like the assignment and documentation + some other things to happen. rci<tab> and then def initialize(a, b) ) to result in something like this... attr_reader :a attr_reader :b # @param a [...]