PEP 8 says:
Python accepts the control-L (i.e. ^L)
form feed character as whitespace;
Many tools treat these characters as
page separators, so you may use them
to separate pages of related sections
of your file
This look like a great idea for me, but in the text editor I use(kate) "control+L" is for save all files. Someone have any solution?
... or I'm losing something here?
Ctrl-L simply refers to the character with ASCII code 12 (form feed, new page). It is called Ctrl-L only because some editors allow you to enter it with Ctrl-L. (For instance, in vim, one can type Ctrl-Q Ctrl-L to enter that character, and it also appears as ^L). In Kate, Ctrl-L is a shortcut for saving all files, so you cannot type it that way and I'm not sure there is any way of entering that character easily.
As a Kate developer, I unfortunately have to tell you that such control sequences are not supported. In fact, Kate often treats these files as binary files, since such characters are not human readable text. So in short: Try to avoid ^L.
You can create a plugin, and disable the shortcut Ctrl + L from the menu: Settings -> Configure shortcuts
Related
The Unicode character U+1d134 is the musical symbol for "common time"; it looks like a capital 'C'.
But using Python 3.6, when I specify '\U0001d134' I get a glyph that seems to indicate an unknown symbol. On my Mac, it looks like a square with a question-mark in it.
Is the inability to display the corresponding glyph simply a font limitation, or is it something else? (Like maybe something I'm doing wrong....)
For clarity, I want to use this and other such symbols in an app I'm writing, and would like to find out if there's a way to do this.
The problem lies not in your code but in your local system. You don't have any font installed that contains the character ๐ด "MUSICAL SYMBOL COMMON TIME".
That is also the reason none of your browsers can display it. Usually, browsers are quite good in hunting down any font that can display a certain character. Reason they all fail is what's in the paragraph above.
But โ as it happened,
>>> print ('\U0001d134')
๐ด
worked for me, displaying this:
I pasted it into UnicodeChecker, which helpfully listed 'all' fonts that contain this character: only one, Bravura. It's an Open Source font so go ahead and download it. (Be careful to follow proper procedures if you want to distribute it along with your app.)
To think that I only had that font installed because of an earlier SO question.
Is there a way to change which character is used for QT's QTextOption.ShowTabsAndSpaces flag?
I find that the default character that's used for viewing whitespace (specifically spaces) stands out a little too much. I'd like to change the font or character used so that it's less distinct.
It looks like the character used is unicode "Middle Dot", ยท (U+00B7) and I'd like to use, say, U+02D1 ห.
Ideally I'd like to be able to set it to whatever the user wants.
I've been searching through the Qt docs and have only been able to find how to turn this flag on (here).
EDIT:
I guess I should show some code... Here's how I'm currently adding the whitespace indicators:
opts = self.document().defaultTextOption()
opts.setFlags(opts.flags() | QTextOption.ShowTabsAndSpaces)
self.document().setDefaultTextOption(opts)
Running Python 3.4 and PyQt4, but should be able to port C++ code over.
EDIT2:
Thanks to Andrei Shikalev's answer below, I've posted a feature request for this on the QT tracker: https://bugreports.qt.io/browse/QTBUG-46072
Currently we could not change characters for tabs and white space. This characters hardcoded in Qt source for QTextLayout:
QChar visualTab(0x2192);
...
QChar visualSpace((ushort)0xb7);
More info in source for QTextLayout on GitHub.
You can create feature request for tabs and white spaces custom characters. IMHO this feature will be useful for custom-looking editors, based on Qt.
I'm using the pipe-pane of tmux to record what I was doing, and I want to parse and take a account of the commands I typed etc. But when I got the xxx.log file, and opened it with vim, I found that there are many special word like ^H,^M,^G etc,see the sample:
administrator#ubuntu:~$ echo "hello,world[K[K[K[K[K[K[K[K[K[K"
h
administrator#ubuntu:~$ ^G^G^G^G
administrator#ubuntu:~$
I know that tmux records everything I typed, but some keys with Ctrl/alt prefix can not be displayed, and I want to ignore them. How can I archive that with perl/python or C, any tips?
In the general case, this is hard, because some programs make extensive use of display control codes to draw dialogs etc. If you just want to drop any individual unprintable characters, that's easy with tr, but if you want to remove display control codes, too, that's significantly more complex, and basically requires knowledge about which terminal emulator you are working with. A plausible target would be xterm but I'm not aware of any off-the-shelf solutions for stripping xterm display codes.
Is there a way to show "Soft Tabs" (spaces) in TextMate? View โ Show Invisibles works well for keeping track of indentation if you're using tabs for indentation. Unfortunately in languages where indentation is semantic you generally have to use spaces.
(Python, YAML, HAML, CoffeeScript)
Any suggestions for showing this whitespace or keeping track of soft indentation in TextMate? Should I keep holding out for Textmate2?
Alternative strategies and suggestions are also welcome.
The latest version of TextMate 2 highlights spaces when Show Invisibles is enabled.
EDIT:
You can even customize which invisibles to show with which character by modifying the invisiblesMap property in .tm_properties file.
From the TextMate changelog:
This can be set to a string which is used to control which glyphs are used for invisible characters. Add either \n, \t, or a space to the string, followed by the glyph that should be used to render the character, or prefix it with ~ to disable rendering of that character. For example to disable rendering of spaces and render tabs as โ add this to .tm_properties: invisiblesMap = "~ \tโ".
Sidenote:
THIS IS NOT THE CASE ANYMORE, functionality has been restored.
According to the Log of 2013-10-23 (v2.0-alpha.9489): "Show Invisibles will no longer treat space as an invisible (which was added in previous build) as it was causing issues with right-to-left rendering and combining marks used after spaces. The feature might be back, but needs to be implemented differently."
You can use soft tabs - as described here. I have also problem to find it when I needed this feature;)
In Python, is there a mean to enforce the use of spaces or tabs indentation with a per file basis ?
Well, perhaps "enforce" is too strong, more like a "recommendation".
I keep receiving patch files with mixed indentation and this is annoying... (to say the least) Python itself can tell when there is a problem, but I am searching something to do that at the editor level, like it exists for the charset.
Edit : Ok, my question wasn't clear, I am asking this because I keep receiving corrections and patches in any mix of tab/space you can imagine. I am using Mercurial as a DVCS, perhaps something exists at this level ?
Tim Peters has written a nifty script called reindent.py which converts .py files to use 4-space indents and no tabs. It is available here, but check your distribution first -- it may have come bundled in an Examples or Tools directory. (On the latest LTS Ubuntu, it is provided by the python2.7-examples package.)
If you can set up a Mercurial hook you should be able to run all files through reindent.py.
By the way, if you are using unix, then your system may also have the expand (and unexpand) command, which convert all tabs to spaces (and spaces to tabs). However, in this case, I think reindent.py is the right tool.
Look at the tabnanny module: โ Detection of ambiguous indentation.
This is something your editor should do for you. Most editors (try Notepad++ for example, it's free) will let you set whether hitting tab enters a tab character or a number of spaces. I'd recommend using two spaces instead of tab in all files (I find 4 is too much). Using spaces instead of tabs is better as it means that you can indent stuff using both the space & tab keys without worrying about messing up your files.
If you have files that have a mix it isn't hard to write your own script to convert tabs to spaces
As explicited in PEP 8, never mix tabs and space. However, a file with both may just run...
As it says there:
The most popular way of indenting Python is with spaces only. The
second-most popular way is with tabs only. Code indented with a mixture
of tabs and spaces should be converted to using spaces exclusively.
When invoking the Python command line interpreter with the -t option, it issues
warnings about code that illegally mixes tabs and spaces. When using -tt
these warnings become errors. These options are highly recommended!
the solution is therefore to use as a default:
python -t my_mixed_code.py
To answer at the editor level, this depends on the editor, please specify!