Insert an Inline Code with Back Tics do not work in Medium.com - medium.com-publishing-api

Following this Blog:
https://medium.com/blogging-guide/how-to-insert-a-code-block-or-inline-code-into-a-medium-article-7b697bd12e0a
It should be simple to add inline Code with Back Tics (`).
However it does not work for me - it only displays the back tics as characters:
Is there something that I miss?

If you are using other than "Standard US English Keyboard" then medium formatting options may vary.
For instance, I am using ABC-QWERTZ layout on my mac.
For me:
To enter into inline code block:
[Single backtick + space key] worked.
To come out from inline code block:
[Single backtick key]
Start writing after pressing key.
On U.S. Keyboard:
To enter into inline code block:
[Single backtick].
To come out from inline code block:
[Single backtick key]
Note:
When you want to add inline block in the middle of sentence, add one space before pressing single backtick.

For me none of the backtick solutions worked, but at least for code blocks (not inline code between two words)
ALT + CMD + 6
did the job.
For MAC Users:
⌥ + ⌘ + 6

If you type the code rather than highlighting existing code, and start with a backtick, you enter inline code mode. To escape, another backtick doesn't work for me - I have to use right arrow.
Selecting code and pressing backtick just deletes the code and displays a backtick. Pretty useless really...

It's a quite old question, but i found a way on French keyboard to it : You need to use the # button (and not the ` button), which is fact at the same place on an English keyboard :

Related

How to prevent automatic hyperlink detection in the console of Firefox/Chrome developer tools?

Something that drives me nuts in the developper tools of Chrome (106) and Firefox (105) is the fact that whenever some text logged to the console via console.log(text) happens to contain a hyperlink, this link is not only turned clickable (I can live with it even when I usually prefer to have just plain text) but is abbreviated, if it is a long link. So when I want to control what precise link is in some variable, I cannot just write e.g. console.log(img.src), because some of the interesting information of the link is hidden.
You can try yourself with
var href = 'https://stackoverflow.com/search?q=%5Bgoogle-chrome-devtools%5D+%5Bconsole.log%5D+%5Bfirefox-developer-tools%5D+%5Bhyperlink%5D+automatic+detection&someMoreStuffTomakeTheLinkLonger';
console.log(href);
In both, Firefox and Chrome, the output for me contains some '...', e.g. in Firefox I obtain as output:
https://stackoverflow.com/search?q=%5Bgoogle-chrome-devtools…link%5D+automatic+detection&someMoreStuffTomakeTheLinkLonger
thus hiding the part after "-devtools". (Chrome hides a slightly different part). The console is mostly a debugging tool. I log things because I want to see them, not hide them. I always need to either hover with the mouse and wait for the tooltip (doesn't allow me to copy fractions of the link) or to right click copy the link and paste it somewhere where I can see it completely. Or take a substring to remove the "https://" in the front. But note that the variable isn't necessarily a single hyperlink, but can be any text containing several such hyperlinks. I didn't find a way to force console.log to just print plain text all content. Did anybody meet this problem as well and find a workaround?
I made this a community wiki answer, because the main insight is not from myself but from the comments. Feel free to improve.
The console.log() function allows several arguments, which allows also a formatted output similar to printf in some languages. The possibilities of formatting can be found in the documentation of console.log() on MDN. In any case, this formatted output provides a solution at least for Chrome, as #wOxxOm pointed out in the comments:
console.log('%O', href) // works in Chrome
This is rather surprising, because %O is described at MDN as
"Outputs a JavaScript object. Clicking the object name opens more information about it in the inspector".
It seems there is no 'clicking' in Chrome when the object is a string.
There is also %s for string output, but this just gives the standard behavior of replacing links in both browsers. And for Firefox none of the above two formatting options works. There one really has to replace the protocol "https://" by something that is not recognized as link. A space behind ':' seems enough, so "https: //". It turns out, that one can also insert a formatting string "https:%c//", which can even be empty, and thus yield an output which is the complete link and can be copied as well:
console.log(href.replace(/(https?:)/, "$1%c"), ""); // works in Firefox
In particular the FF solution is cumbersome, and there might also be several links within one console-output. So it is useful to define one's own log-function (or if one prefers, redefine console.log, but note the remark at the end)
function isChrome() {...} // use your favorite Chrome detection here
function isFirefox() {...} // use your favorite Firefox detection here
function plainLog() {
const msg = arguments[0];
if (isChrome() && arguments.length == 1 && typeof msg == "string") {
return console.log("%O", msg);
}
if (isFirefox() && arguments.length == 1 && typeof msg == "string") {
const emptyStyle = ""; // serves only as a separator, such that FF doesn't recognize the link anymore
const reg = /(https?:)\/\//g;
const emptyStyles = []; // we need to insert one empty Style for every found link
const matches = msg.matchAll(reg);
for (let match of matches) {
emptyStyles.push(emptyStyle);
}
return console.log(msg.replace(reg, '$1%c//'), ...emptyStyles);
}
return console.log(...arguments);
}
For browser detection isChrome() and isFirefox() see e.g. here on SO.
One can of course extend the redefinition also to the other console functions (console.info, console.warn, etc.)
The downside of the redefinition of console.log is that usually every output of the console shows also the last entry of the call stack as a practical link to the source of the logging. But due to the redefintion, this link is now always to the same place, namely the file and line number where plainLog() is defined and calls console.log(), instead of the place where the new log command plainLog() was called. This new problem is described on SO here, but the solution (see comment) is again a bit involved and also not completely satisfying to serve as a replacement for the built-in console.log . So if links appear only rarely in the logging, it's probably better to switch to the redefined plainLog() only for these links.

In Visual Studio Code Ctrl+V is not working

In Visual Studio Code Ctrl+V is not working on editor.
However from the command palette Ctrl+Shift+V is working.
I´ve had this problem when I enabled the "VIM" plugin for VSCode.
After uninstalling it, the problem was fixed.
Open the keyboard shortcuts preferences by pressing CTRL + SHIFT + P and search for open keyboard shortcuts file.
Then, search for the editor.action.clipboardPasteAction property. In your case, it might be CTRL+SHIFT+V. Try changing it to Ctrl + V. Like so:
Solution as of 2022
You could also CTRL + SHIFT + P and search for open keyboard shortcuts (JSON) and paste the following:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.sendSequence",
"when": "terminalFocus && !accessibilityModeEnabled && terminalShellType == 'pwsh'"
},
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear"
}
]
#WebD'is answer is very helpful and I have upvoted it. But my comment focused on whether there was a conflicting binding for CTRL-V and how to find it. You can literally type "Ctrl+V" (note the "plus+" sign, not a hyphen) and it will find all keybindings that use that binding in whole or part. I suggest that there must be a something else also bound to CTRL-V.
Since this original answer, vscode introduced another way to see what other commands might be bound to given keystrokes. With the Gear/Keyboard Shortcuts file open click on the little keyboardy icon to the right (or Alt+K with this file open) and it will indicate Recording Keys next to it. Now you can literally press Ctrl+V (or whichever keybinding you are interested in) and those corresponding commands, if any, that use that keybinding will be filtered up.
Remember to disable the Recording Keys functionality by clicking the keyboardy icon if you want to go back to regular searching in the Keyboard Shortcuts file.
I have the same problem: can't CTRL+X, CTRL+C, CTRL+V on VSCode editor.
I uninstall the Vim extension and the problem is fixed.
If you install the vim extension for visual studio code and find that ctrl + x, ctrl + v .. or other shortcuts stopped working, this is because they are overwritten by extension.vim_
If you prefer to get those shortcuts back go to keyboard shortcuts (ctrl + shift + p, then search for open keyboard shortcuts file).
Search for extension.vim_ and check too see if any shortcuts are
assigned to your key combination like ctrl + v. Remove it (right click, delete).
Also check for any other conflict by searching the file.
Save the file, it should work now.
For future searchers who do not have Vim (or any other extension) installed which is causing the issue, and who might have verified that their keyboard bindings are correct....
I have the Salesforce Extension Pack installed and had right-clicked on a file and run SFDX: Deploy Source to Org. The deployment had errors, so in the Panel area (which I have at the bottom of my screen) [see image] I had clicked on both the OUTPUT and PROBLEMS tabs, which shifted focus away from my PowerShell TERMINAL tab.
My Ctrl-V issue was when I was trying to correct my Apex code in the EDITOR pane. Ctrl-V was not pasting the code I had just Cut or Copied (but right-clicking and choosing Paste was working).
I ultimately discovered, when I changed my Panel focus back to my PowerShell TERMINAL tab, that ALL of the Ctrl-V pasting I had attempted had shown up after my PowerShell prompt! ["circled" in blue in image]
tl;dr
Make sure your pasted text did not show up in your TERMINAL - even if it is not in focus or even if your cursor is in another Panel tab or in the EDITOR.
From File > Performance > Keyboard Shortcuts > search paste > just try to remove or rest some keybinding with right click on paste or default:paste
If you have the Vim extension installed, you may set the vim.useSystemClipboard in the vim extension setting to true. Then you can paste the content from the clipboard by simply pressing p in the NORMAL mode, or use Ctrl+V in the INSERT mode.
This problem happened to me after I left VSC update itself (currently 1.53.0). It had been converted to Shift-Insert.
Go to File->Preferences->Keyboard shortcuts. Find the editor.action.clipboardPasteAction and double click it, then type Ctrl+V.
+1 for this - in case this helps anyone:
In my case it was only happening in the Thunder Client extension's text fields.
The culprit for me was the Indent on Paste extension (I'm on a Mac, so it was cmd+v instead of ctrl+v - but it fires the same event in VS Code).
I've left issue comments on the Thunder Client and Indent on Paste repos respectively, should anyone wish to add to those.
Look if and remove any VS Code extension :
for example - "Awesome Emacs Keymap" in my case, or any other keymaps installed.
i.e. : FILE/Preferences>/extensions and then look if any special keymap was installed
Modify the setting of vscode:
Settings - input:vim ctrl key - unselect: Enale some vim ctrl key commands that override otherwise common operations, like ctrl + c
go to extensions search Emacs keymap and uninstall it
There should something conflicting to your any previous keyboard shortcut
like in my case for Change All Occurrence: (Ctrl-C + Ctrl-A), vs code, confused with
Ctrl-C for a copy shortcut to this : (Ctrl-C + Ctrl-A), so I change this to (Shift-C + Shift-A), My Issue resolved.
Go to File>Preference>keyboard Shortcuts
Then Check for Copy and paste and enter the Ctrl+C and Ctrl+v shortcuts
Happy Coding ;)
None of the issues above solved this for me. I had a key binding Ctrl+C Ctrl+L. So when I pressed Ctrl+C it was in a state where it was waiting for the next key to be pressed and wouldn't do anything.
This showed up in the toolbar like so (an example):
This didn't come up in the list of keybindings when searching for Ctrl+C. So I found it be looking through the list.
Remove all cmd+v or in windows ctrl+v associated keybindings.
For me the solution was going through my extensions and disabling them one by one to find the culprit.
I had 'Paste and Indent' enabled which was messing up copying and pasting.
Just had to disable it and reload vs code.
Open Settings > keyboard shortcuts
Search for Ctrl + c
Delete the mapping for vim.
i have same problem
step:1
ctrl+shift+p
step:2 find
Open keyboard shortcuts
step:3
find paste
then you can see
editor.action.cliboardPasteAction
right click then changekeybinding if key wrong
or remove key if u found two same line(editor.action.cliboardPasteAction)
in my case is 2nd one(so i removed)
In some cases, if you use remote ssh connects to a remote server and code there, ctrl + V may not be useful because that your remote server has a high balance, you can try to uninstall some useless plugins in that remote server then reload vscode.
I have disabled all extensions, and VS Code hangs for a few seconds whenever I try to paste something. This occurs with Ctrl+V, Shift+Ins and also with right click + Paste.
It hangs, and then nothing happens.
[UPDATE]
I simply reinstalled it, and that solved the issue for me.
In my case just the relaunch of VSCode solved the issue. My key bindings were fine.
"Paste JSON as Code" was my offender, as well as a few other ones. I got a little extension happy there for a bit.
Its easy don't worry, you need to search using ctrl+shift+p and find Prefernces: Open Keyboard Shortcuts(JSON) and add this dict
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+c",
"command": "editor.action.clipboardCopyAction",
"when": "textInputFocus"
}
]
I thins it's very helpfull good luck :)

How to add custom code snippets in VSCode?

Is it possible to add custom code snippets in Visual Studio Code? And if so, how? VSCode is based on Atom, so it should be possible.
Hit > shift + command + p and type snippets
Select Preferences: Configure User Snippets
Choose the language type for which you want to add the custom snippet in the vscode inputbox
vscode has comments to explain on how to add a snippet, as described on :> vsdoc or you can follow the next link with a short guide:
Lets say, we want to open custom snippets for the language GO. Then we can do:
Hit > command + p
Type: go.json + enter And you land on the custom snippet page
Snippets are defined in a JSON format and stored in a per-user (languageId).json file. For example, Markdown snippets go in a markdown.json file.
Using tools:
Snippet Generator extension (recommended)
Online snippet generator
Option 1 - Use the Snippet Generator extension.
It supports code to JSON conversion with optional scope support and space to \t conversion.
Demo:
Option 2 - Another extension is snippet-creator (deprecated).
After installing it, all you have to do is to :
Select the code that you want to make a snippet.
Right-click on it and select "Command Palette"(or Ctrl+Shift+P).
Write "Create Snippet".
Choose the type of files needed to be watched to trigger your snippet shortcut.
Choose a snippet shortcut.
Choose a snippet name.
Option 3 - check this website. you can generate snippets for vs code, sublime text, and atom.
Once snippet being generated on this site. Go to the respective IDE's snippet file and paste the same. For example for a JS snippet in VS code go to File->preference->user snippet then it opens javascript.json file then paste the snippet code from an above site inside this and we are good to go.
As of version 0.10.6 you can add custom snippets. Read the documentation on Creating your Own Snippets.
You can find/create custom snippets by placing the json file in C:\Users\<yourUserName>\AppData\Roaming\Code\User\snippets.
For example, a custom javascript snippets would be in a \snippets\javascript.json
You can also publish you snippets which is a really neat feature as well. John Papa created a nice angular + typescript snippet you can download as an extension in the marketplace.
Here is an example snippet taken for the documentation on a javascript for loop:
"For Loop": {
"prefix": "for",
"body": [
"for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {",
"\tvar ${element} = ${array}[${index}];",
"\t$0",
"}"
],
"description": "For Loop"
},
Where
For Loop is the snippet name
prefix defines a prefix used in the IntelliSense drop down. In this case for.
body is the snippet content.
Possible variables are:
$1, $2 for tab stops
${id} and ${id:label} and ${1:label} for variables
Variables with the same id are connected.
description is the description used in the
IntelliSense drop down
You can check out this video for a quick short tutorial
https://youtu.be/g1ouTcFxQSU
Go to File --> Preferences --> User Snippets. Select your preferred language.
Now type the following code to make a for loop snippet:
"Create for loop":{
"prefix": "for",
"body":[
"for(int i = 0; i < 10; i++)",
"{",
" //code goes here",
"}"
],
"description": "Creates a for loop"
}
You are done.
Type "for" in the editor and use the first prediction.
SHORTCUT
install snippet-creator extension (now deprecated).
Highlight the code that you need to make snippet.
press ctrl+shift+P and type "Create snippet" on the command palette and
press ENTER.
select language for which you want to create snippet(eg:-CPP), then type
snippet name, type snippet shortcut and then type snippet description.
You are now good to go.
Type the snippet shortcut in the editor that you entered in step 4, and select the prediction (if no prediction comes press ctrl+space) that comes first.
Hope this helps :)
Note: goto File->Preferences->User Snippets. Then select the language in which youcreated the snippet. You will find the snippet there.
You can add custom scripts, go to File --> Preferences --> User Snippets. Select your preferred language.
If you choose Javascript you can see default custom script for console.log(' '); like this:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
There's a VSCode Plugin called: snippet-creator (now deprecated).
After installing it , all you have to do is to:
Select the code that you want to make it a snippet.
Right click on it and select "Command Palette"(or Ctrl+Shift+P).
Write "Create Snippet".
Choose type of files needed to be watched to trigger your snippet shortcut.
Choose a snippet shortcut.
Choose a snippet name.
That's All.
Note : if you want to edit your snippets , you will find them in [fileType].json
Example : Ctrl+P , then select "javascript.json"
I tried by adding snippets in javascriptreact.json but it didn't worked for me.
I tried adding snippets into global scope, and it's working like charm.
FILE --> Preferences --> User snippets
here select New Global Snippets File, give name javascriptreact.code-snippets.
For other languages you can name like [your_longuage].code-snippets
This is an undocumented feature as of now but is coming soon. There is a folder you can add them to and they will appear, but it may change (its undocumented for a reason).
Best advice is to add this to the uservoice site and wait til its final. But it is coming.
On MacOS:
Open the VSCode
Code -> Preferences -> User Snippets
Search for "python" (or any language)
Write your snippet like this:
{
"Write pdb": {
"prefix": "pdb",
"body": [
"import pdb; pdb.set_trace()",
"$2"
],
"description": "Write pdb.set_trace() to debug Python scripts"
}
}
Save the file with command + S.
VSCode introduce this in version 0.5, see here.
Snippet syntax follows the TextMate snippet syntax and can write in User Preferences.
If you'd rather not deal with writing your snippets in JSON, check out Snipster. It lets you write snippets as you would write the code itself - not having to wrap each line in quotes, escape characters, add meta information, etc.
It also lets you write once, publish anywhere. So you can use your snippet in VS Code, Atom, and Sublime, plus more editors in the future.
This may not be a real answer (as some have answered above), but if you're interested in creating custom code snippets for other people, you can create extensions using yeoman and npm (which by default comes along with NodeJS) . NOTE: This is only for creating snippets for other's systems. But it also works for you too! Except you need JS code for whole thing.
You can add custom scripts, go to File --> Preferences --> User Snippets. Select your preferred language.
Like mine code is go, I do it as below:
"channel code": {
"prefix": "make_",
"body": [
"${1:variable} := make(chan ${2:type}, ${3:channel_length})",
"$4"
]
}
explanation: $1 will take your tabs & to give hints what are those tabs values, we make it like ${1:some_variable} which could give us hints what are those
I hope, it helps!

texniccenter shortcut for user defined command

Is there any chance to insert a "user defined command" in texniccenter by shortcut?
I want to insert a "user defined command" but all i found at the shortcut menu was to edit the shortcuts by shortcut. Even in the new Alpha version i didn't found any hint how to do that.
have someone an idea?
Go into the Insert menu, then under "Own Text Modules" select Manage. You can add your own in there and then add the "Own Text Modules" to the shortcuts.
J found a solution for this Problem, especially if you want to add e.g. \bm{} to an existing word or phrase.
First of all, define your "Own Text Module", for which you want to create a shortcut. Then, try to use this command with your keyboard (Alt + I + M + (x)” where (x) is the number in front of your own text module within the menu.
For the german Version, it is (“Alt + E + B + (x)”). Remember this combination. Then assign this shortcut with the program AutoHotkey. The AutoHotkey script looks like this (for the german Version):
%%%
^b::Send !eb 6
Return
%%%
This means: ^b(= <kbd>Ctrl</kbd> + <kbd>B</kbd>) sends the command: ! (Alt)eb 6
I had to add a space between b and 6, however, otherwise it did not work.
It works great for me.

Looking for a more flexible tool than GNU indent

When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:
-int send_pkt(tpkt_t* pkt, void* opt_data);
-void dump(tpkt_t* bp);
+int send_pkt(tpkt_t * pkt, void *opt_data);
+void dump(tpkt * bp);
I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info page, and visited a half a dozen pages that Google suggested and I can't find an option to do this.
I tried Artistic Style (a.k.a. AStyle) but can't seem to figure out how to make it indent in multiples of 4 but make every 8 a tab. That is:
if ( ... ) {
<4spaces>if ( ... ) {
<tab>...some code here...
<4spaces>}
}
Uncrustify
Uncrustify has several options on how to indent your files.
From the config file:
indent_with_tabs
How to use tabs when indenting code
0=spaces only
1=indent with tabs, align with spaces
2=indent and align with tabs
You can find it here.
BCPP
From the website: "bcpp indents C/C++ source programs, replacing tabs with spaces or the reverse. Unlike indent, it does (by design) not attempt to wrap long statements."
Find it here.
UniversalIndentGUI
It's a tool which supports several beautifiers / formatters. It could lead you to even more alternatives.
Find it here.
Artistic Style
You could try Artistic Style aka AStyle instead (even though it doesn't do what you need it to do, I'll leave it here in case someone else finds it useful).
Hack around and change its behavior editing the code. It's GNU after all. ;-)
As it's probably not the answer you wanted, here's another link: http://www.fnal.gov/docs/working-groups/c++wg/indenting.html.

Resources