VIFM: Remapping control right/left in command-line mode - readline

I'm not a big fan of the command line readline keyboard shortcuts so I'm hoping to remap C-Right/C-Left to navigate one word back/forward and C-BS and C-Del to delete one word back/forward. However, after reading the documentation and forumns, I'm not able to figure out how to do this.
Currently, when C-left/C-right are typed in the command line, the cursor doesn't move and instead keycodes are inserted (C-left = [1;5D, C-right = [1;5C). I've tried many remappings but the mappings that I would think would work best for this are:
cmap <C-right> <A-f>
cmap <C-left> <A-b>
I was able to figure out how to delete one word back using the following mappings (on further review there is documentation in the VIFM manual regarding mapping BS):
cnoremap <BS> <C-w>
cnoremap <C-h> <C-w>
However, I'm still uncertain on how to map delete one word forward using C-Del. When I use the following remapping for C-Del, the result is that one character to the left of the cursor is deleted. Note, when I use other C-* combinations for delete word forward the remappings actually works making me think that it may not be possible to remap C-Del:
cmap <C-Del> <A-d>
I'm using VIFM version 0.12 on Arch Linux. Any suggestions?

List of keys that are supported by angle-bracket notation is available in the documentation. And combinations of Ctrl with arrow keys are not there.
See this GitHub issue for a discussion of why and an example of how to work around it:
" ctrl-right
cnoremap <esc>[1;5C <a-f>
" ctrl-left
cnoremap <esc>[1;5D <a-b>
" ctrl-del
cnoremap <esc>[3;5~ <a-d>
At this point I'm still not sure that these sequences are common enough among different terminal types to be hard-coded and not cause trouble.

Related

How to indicate a point at which Emmet code is supposed to start?

Typically an Emmet command starts at a line or after a space, like h1>{Header} or like text sup>{super}. However, I am writing something like x<sup>2</sup> or x<sub>2</sub> over and over again, and can't obviously use an Emmet command to do this with a small number of keystrokes. If I write xsup>{2} and tab, obviously that's not going to work. I can write x sup>{2} and tab, but then I have to go back and erase my space.
Now I know I could do something like this:
{x}+(sup>{2})
But the problem with THIS solution is that, in fact, I'm often writing much longer lines of mathematical expressions involving many instances of super- and sub-scripts. In fact, pretty often I write super-scripts that have their own sub-scripts. When I pursue this sort of solution, I really have to plan out my entire Emmet command before I start writing it, and then if I made a mistake it is not easy to go back and edit. It's much better if I can write these in small increments that can be fixed in equally small and local ways, as is usually the flow when writing in Emmet.
So what I was hoping for, if it exists, is some sort of "start" symbol for Emmet commands other than space. For instance, if $ were such a symbol, then x$sup>{2} would do the job. If such a symbol existed, it would mark the start of Emmet code and get auto-removed after tabbing.
Alternately if that doesn't exist, it would be great if there were some command you could give to delete the white space after tabbing. So for instance, it could be x sup>{2}$ where tabbing after the $ instructs Emmet to remove the white space which precedes the Emmet command.
Does any such solution exist in Emmet?
In Sublime Text, you can run Enter Abbreviation Mode command: it will capture anything you type as abbreviation, validate it and show interactive preview. Then simply Tab or Enter to expand it or Esc to reset.
See more at https://github.com/emmetio/sublime-text-plugin#disable-abbreviation-capturing

Open and extract information from large text file (Geonames)

I want to make a list of all major towns and cities in the UK.
Geonames seems like a good place to start, although I need to use it locally (as opposed to the API) as I will be working offline while using the information.
Due to the large size of the geonames "allcountries.txt" file it won't open on Notepad, Notepad++ and Sublime. I've tried opening in Excel (including the Data modelling function) but the file has more than a million rows so this won't work either.
Is it possible to open this file, extract the UK-only cities, and manipulate in Excel and/or some other software? I am only after place name, lat, long, country name, continent
#dedek's suggestion (in the comments) to use GB.txt is definitely the best answer for your particular case.
I've added another answer because this technique is much more flexible and will allow you to filter by country or any other column. i.e. You can adapt this solution to filter by language, region in the UK, population, etc or apply it the cities5000.txt file, for example.
Solution:
Use grep to find data that matches a particular pattern. In essence, the command below is saying, find all rows where the 8th column is exactly "GB".
grep -P "[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\tGB\t" allCountries.txt > UK.txt
(grep comes standard with most Unix systems but there are definitely tools out there that can do it on Windows too.)
Details:
grep: The command being executed.
\t: Shorthand for the TAB character.
-P: Tells grep to use a Perl-style regular expression (grep might not recognize \t as a TAB character otherwise). (This might be a bit different if you are using another version of grep.)
[^\t]*: zero or more non-tab characters i.e. an optional column value.
> UK.txt: writes the output of the command to a file called "UK.txt".
Again, you could adapt this example to filter on any column in any file.

Erlang and Elixir's colorful REPL shells

How does Learn some Erlang or IEx colorize the REPL shell? Is kjell a stable drop-in replacement?
The way this is done in LYSE is to use a javascript plugin called highlight.js, so LYSE isn't actually doing it, your browser is. There are plugins/modes for most mainstream(ish) languages available for highlight.js. If the web is what you are interested in, this is one way to do it (except for when a user can't use JS or has it turned off).
This isn't actually the shell being highlighted at all, nor is it useful anywhere outside of browsers. I've been messing around with a way to do this more generically, initially by inserting static formatting in HTML and XML documents (feed it a document, and it outputs one with Erlang syntax highlighted a certain way whenever this is detected/tagged). I don't yet have a decent project to publish for this (very low on my priority list atm), but I can point you in the direction of some solid inspiration: the source for wx:demo.
Pay particular attention to the function demo:code_area/1. There you will see how the tokenization routines are used to provide highlight hints for the source code text display area in the wx:demo application. This can provide a solid foundation to build your own source highlighting/display utility. (I think it wouldn't be impossible, considering every terminal in common use today responds correctly to ANSI color codes, to write a plugin to the shell that highlights terminal input directly -- not that there is a big clamor for this feature at the moment.)
EDIT (Prompted by a comment by Fred the Magic Wonder Dog)
On the subject of ANSI color codes, if this is what you are actually after, they are easy to implement as a prepend to any string value you are returning within a terminal. The terminal escapes them, so you won't see the characters, but will perform whatever action the code represents. There is no termination (its not like a markup tag that encloses the text) and typically no concept of "default color to go back to" (though there are a gajillion-jillion extensions to telnet and terminal modes that enable all sorts of nonsense like this).
An example of basic colorization is the telcon:greet/0 and telcon:sys_help/0 functions in the v0.1 code of ErlMUD (along with a slew of other places -- colorization in games is sort of a thing). What you see there is a pre-built list per color, but this could be represented any way that would get those values at the front of the string. (I just happened to remember the code value sequences, but didn't remember the characters that make them up; the next version of the code represents this somewhat differently.) Here is a link to a list of ANSI color codes and a discussion about colorizing the shell. Play around! Its nerdy fun, 1980's style!
Oh, I almost forgot... if you really want to go down the rabbit hole without silly little child toys like ncurses to help you, take a look at termcap.
I don't know if kjell is a stable drop-in replacement for Erl but it wouldn't be for IEx.
As far as how the colors are done; to the best of my knowledge it's done with ANSI Escape Sequences.

Flip doxygen's graphs from top-to-bottom orientation to left-to-right

The doxygen graph for "includes" and "is included by" are created with nesting depth increasing from top to bottom (using 1.8.5).
Since we have mostly shallow graphs with many nodes, this leads to very wide graphs with ugly horizontal scroll bars. Is there a way to teach doxygen to create these graphs in a left-to-right orientation, the way it creates caller/call graphs?
I know that graphviz/dot supports this, but can't find a way to tell doxygen my preference.
There is a similar question asked recently which I am duplicate answering:
Doxygen: Is it possible to control the orientation of dependency graphs?
After looking for the same myself and finding nothing, the best I can offer is a hack using the graph attribute rankdir.
Step 1) Make sure Doxygen keeps the dot files. Put DOT_CLEANUP=NO in your confige file.
Step 2) find your dot files that Doxygen generated. Should be in the form *__incl.dot. for steps below I will refer to this file as <source>.dot
Step 3a) Assuming the dot file did not explicitly specify rankdir (usually it is TB" by default), regenerate the output with this command.
dot -Grankdir="LR" -Tpng -o<source>.png -Tcmapx -o<source>.map <source>.dot
Step 3b) If for some reason rankdir is specified in the dot file, go into the file and add the rankdir="LR" (by default they are rankdir is set to "TB").
digraph "AppMain"
{
rankdir="LR";
...
Then regenerate the output with:
dot -Tpng -o<source>.png -Tcmapx -o<source>.map <source>.dot
You need to redo this after every run of Doxygen. A batch file might be handy, especially if you want to process all files. For step 3b, batch replacing text is outside of the scope of this answer :). But here seems to be a good answer:
How can you find and replace text in a file using the Windows command-line environment?

Define every symbol as a command in LaTeX

I'm working on a large project involving multiple documents typeset in LaTeX. I want to be consistent in my use of symbols, so it might be a nice idea to define a command for every symbol that has a specific meaning throughout the project. Does anyone have any experience with this? Are there issues I should pay attention to?
A little more specific. Say that, throughout the document I would denote something called permability by a script P, would it be an idea to define
\providecommand{\permeability}{\mathscr{P}}
or would this be more like the case "defining a command for $n$"?
A few tips:
Using \providecommand will define that command only if it's not been previously defined. So if you're not getting the results you expected, you may be trying to define a command that's been defined elsewhere.
If you wrap the math in your commands with \ensuremath, it will do the right thing regardless of whether you're in math mode when you issue the command:
\providecommand{\permeability}{\ensuremath{\mathscr{P}}}
Now I can easily use \permeability in text or $\permeability$ in math mode.
Using your own commands allows you to easily change the typographical representation of something later. For instance:
\newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}}
would print \vect{x} as a boldfaced x. If you later decide you prefer arrows above your vectors, you could change the command to:
\newcommand{\vect}[1]{\ensuremath{\vec{#1}}}
I have been doing this for anything that has a specific meaning and is longer than a single symbol, mostly to save typing:
\newcommand{\objId}{\mbox{$\mathit{objId}$}\xspace}
\newcommand{\insOp}[1]{#1\mbox{$^+$}\xspace}
\newcommand{\delOp}[1]{#1\mbox{$^-$}\xspace}
However then I noticed that I stopped making inconsistency errors (objId vs ObjId vs ObjID), so I agree that it is a nice idea.
However I am not sure if it is a good idea in case symbols in the output are, well, single Latin symbols, as in:
\newcommand{\numOfObjs}{$n$}
It is too easy to type a single symbol and forget about it even though a command was defined for it.
EDIT: using your example IMHO it'd be a good idea to define \permeability because it is more than a single P that you have to type in without the command. But it's a close call.

Resources