Mapping a default key binding in vim - keyboard-shortcuts

I want to remap Ctrl-] which is used for jumping to the tags to another key binding.
These mappings work:
:map <F2> <C-]>
:map <A-1> <C-]>
But this mapping doesn't work:
:map <C-1> <C-]>
What might be the reason for this?

I believe the problem is that Ctrl+1 is not a valid ASCII character. From this list
(search for "^^" or "^#" to see the table )
you will see that there are several keybindings such as ctrl+# Ctrl+^ and Ctrl+]
so you are not actually calling Ctrl+2 or Ctrl+6 but their ASCII equivalents.
VIM is designed to be lightweight and fairly platform independent. so if it isn't in the list of ASCII characters you cannot make a binding to it.

It might be getting trapped/filtered by your OS. If you check the mappings, is it listed?

Related

Find MMT Unicode abbreviations for given symbol (e.g. given ☞, find "juri")

The usual IDEs/editors for MMT (e.g. IntelliJ + MMT plugin or jEdit) feature an autocompletion feature for certain useful Unicode characters. For instance, I can type jle and immediately get suggested jleftrightarrow that, upon autocompletion, is replaced by ↔.
Is there a way to find out the reverse association? E.g. I have the symbol ☞ at hand and would like to know the autocompletion abbreviation starting with j — if it exists. For that hand, I would get juri.
The MMT OnlineTools I developed allow this: https://comfreek.github.io/mmteditor.
See screenshot below: if you already have a string full of Unicode symbols that you don't know how to type, just paste it under "how do I type X?". And if you are looking for a specific abbreviation — by Unicode character or by (parts of its) name — use the "abbreviation search" feature.
Internally, my tools pulls from (a copy of) the same resource file that Dennis linked in his answer.
As far as I know, there currently isn't a good way to look up or search for the ASCII abbreviations, except to go straight for the source — which at least has the advantage that it's guaranteed to be up-to-date.
The IDE plugins all have access to an mmt.jar and load their abbreviations from a specific resource file embedded therein. You can find it here on GitHub: https://github.com/UniFormal/MMT/blob/master/src/mmt-api/resources/unicode/unicode-latex-map.
In the long term, we should consider extending that file with a third "field" that gives a short description, and e.g. have a text field in IntelliJ to search for a specific abbreviation.

How do I preserve whitespace in a Maven plugin configuration?

I have a plugin configuration parameter named suffix. I would like the user to be able to specify a newline (a literal character produced by pressing the Return key, not some escaped variant, although I'll get to that) as the value for that parameter.
At the same time, the parameter has a default-value setting. I would like to continue to use that.
How do I specify, in my plugin's configuration stanza, that the suffix parameter should take a newline?
I've tried this:
<suffix><![CDATA[
]]></suffix>
...and this:
<suffix>${line.separator}</suffix>
...(that one actually substitutes the right character in but XML parsing stomps on it) and this:
<suffix><[!CDATA[${line.separator}]]></suffix>
...and this:
<suffix>&x0d;</suffix>
...and this:
<suffix xml:space="preserve">
</suffix>
...all to no avail. Specifically, I see the default value of the parameter instead.
Edit: Interestingly, the whitespace is eaten long before Maven's internals ever get a chance to work on the value. mvn help:effective-pom will show that the whitespace has been removed. Leading, trailing and "only" whitespace content is removed early on in the parsing stage.
This seems to me most likely to be a bug, so I've filed http://jira.codehaus.org/browse/PLX-461 to track it.
The codehaus links don't work anymore, but I found in the maven documentation that since version 3.0.something you can add an attribute xml:space="preserve" to any element you don't want trimmed.
Per instructions, I am answering this question by referring people to the following JIRA: https://issues.apache.org/jira/browse/MNG-5380 (originally at http://jira.codehaus.org/browse/PLX-461 ).
Use $${line.separator}. The double $$ escape it. A chap on the Codehaus IRC channel shared his finding recently, so the credit should actually go to him.

Can you store a theorem number in a variable?

I use \newtheorem and the numbering is done automatically. Sometimes in the text I'll refer to a theorem by this number. I'd like to have a variable equal to this number, so if the theorem number changes, the references will change also.
Yes, it works through the usual \label/\ref-mechanism:
\begin{theorem}\label{thm:foo} ...
That was Theorem~\ref{thm:foo}
(You'll need two runs of LaTeX for the number to settle, you'll get a message about changed references.) Label commands "tack onto" certain things like section headers, captions, items of enumerations and, indeed, theorems and friends.
There are also extensions that can automatically distinguish sections from subsections or figures, for that, see hyperref's \autoref or the cleveref package, but don't worry about it at this point.
You need to put a \label between the \begin{yourtheorem} \end{yourtheorem} and use \ref to refer to it as usual.
You can check this link for explanations with some broader context about theorems

VIM: available shortcuts?

I use many shortcuts for my work in vim.
Other shortcuts are taken by plugins.
Sometimes I would like to add a shortcut for a new command but note afterwards that the shortcut was already taken.
Is there a way to see a list of all available shortcuts in VIM?
(all ctrl-shift-alt shortcuts)
Type :help index to see the mappings (shortcuts as you name them) and commands defined by vim itself.
Type :map to see the mappings defined by your vimrc and plugins. Type :verbose map to know where each mapping was defined.
Also :help map-listing to check what's displayed, but you probably already know about it (it's in map.txt help manual).
If you also want to check which maps or commands are defined by vim itself you can use
:help index
:map //lists all the shortcuts that are assigned.
map also takes a key combination as an argument that lists only the shortcuts assigned to this key combination.
To list all the mappings assigned for Ctrl-V:
:map <c-v>
I found this helpful...
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
If you want a sorted, searchable list of your current mappings to look for unused keys, see my answer at:
How to search in the Vim mapping listing?
As a starting point, for the keys are not mapped by default, see
:help map-which-keys
You can use :map < key > to check a specific mapping. Example: to check Shift-F2, :map S-<F2>.
AFAIK, there's no way of getting a list of what's unmapped without writing code to iterate through each possible key combination and check if there is any output from running :map < key > for that particular key.

Is there any way I can define a variable in LaTeX?

In LaTeX, how can I define a string variable whose content is used instead of the variable in the compiled PDF?
Let's say I'm writing a tech doc on a software and I want to define the package name in the preamble or somewhere so that if its name changes, I don't have to replace it in a lot of places but only in one place.
add the following to you preamble:
\newcommand{\newCommandName}{text to insert}
Then you can just use \newCommandName{} in the text
For more info on \newcommand, see e.g. wikibooks
Example:
\documentclass{article}
\newcommand\x{30}
\begin{document}
\x
\end{document}
Output:
30
Use \def command:
\def \variable {Something that's better to use as a variable}
Be aware that \def overrides preexisting macros without any warnings and therefore can cause various subtle errors. To overcome this either use namespaced variables like my_var or fall back to \newcommand, \renewcommand commands instead.
For variables describing distances, you would use \newlength (and manipulate the values with \setlength, \addlength, \settoheight, \settolength and \settodepth).
Similarly you have access to \newcounter for things like section and figure numbers which should increment throughout the document. I've used this one in the past to provide code samples that were numbered separatly of other figures...
Also of note is \makebox which allows you to store a bit of laid-out document for later re-use (and for use with \settolength...).
If you want to use \newcommand, you can also include \usepackage{xspace} and define command by \newcommand{\newCommandName}{text to insert\xspace}.
This can allow you to just use \newCommandName rather than \newCommandName{}.
For more detail, http://www.math.tamu.edu/~harold.boas/courses/math696/why-macros.html
I think you probably want to use a token list for this purpose:
to set up the token list
\newtoks\packagename
to assign the name:
\packagename={New Name for the package}
to put the name into your output:
\the\packagename.