Center text at top of page in Sublime Text - sublimetext3

In Sublime Text, one can recenter the current line at the center of a page with the show_at_center shortcut. Is there a way to do the same but with the current line moved to the top of the page?

There is no such command by default, although it's easy to create one via a plugin:
import sublime
import sublime_plugin
class SelectionToTopCommand(sublime_plugin.TextCommand):
"""
Jump the viewport in the file so that the selection is at the top of the
file display area. Handy while conducting reviews.
"""
def run(self, edit):
position = self.view.sel()[0]
offs = self.view.rowcol(position.begin())[0] * self.view.line_height()
self.view.set_viewport_position((0.0, offs), True)
self.view.sel().clear()
self.view.sel().add(position)
This defines a new command named selection_to_top that shifts the view of the current file so that the selection (which is just the cursor) is at the top of the viewport.
You can bind it to any key that you find handiest for something like this, or add it to the command palette, etc.
See how to use plugins in Sublime if you're unsure of how to add a new plugin and how to add commands to the command palette if you'd like to add the command there.

Related

PYQT5 Open menu on cursor position in QTextEditor

I have a QTextEditor which I would like to open a menu for user to choose when he press Ctrl+Space.
I was able to capture the key events and create the menu and trigger it.
My problem is to open the menu on the text cursor position.
How do i get the QPoint of the textcursor and not the mouse position?
QTextEdit.cursorRect returns a rectangle (in viewport coordinates) that includes the cursor.
You're probably imlementing autocompletion/intellisense, it which case I'd recommend using QCompleter instead of QMenu. Take a look at Custom Completer Example.
You can override QTextEdit.keyPressEvent or use eventFilter to capture Ctrl+Space shortcuts and call completer.complete(rect) to show popup.

Is there any way to set background color of lines in GoLand (JetBrains IDE)?

Is there any way to set the background color for certain lines in GoLand (JetBrains IDE) so I can sign what code I have read?
Is it possible to do this? Does not matter if it's an IDE function or via some plugin.
There are a few ways to mark some lines and add them to the "Reading" list:
Bookmarks. It is built-in functionality in IntelliJ-based IDEs. You can go to the line with Authenticator interface declaration and select Edit | Bookmarks | Toggle Bookmark in the main menu. All bookmarks are available in View | Tool Windows | Bookmarks.
3rd-party plugins. I'm aware of MultiHighlight plugin that supports selection of the piece of code.
Sticky selection can do that trick.
there is the brief intro about it:
you can mark a selection to be permanently highlighted, even when your caret moves away. Inspired by "Style token" of Notepad++.
You can define an arbitrary number of Paint Groups. Selecting the appropriate editor action (keystroke or context menu), the all occurrences of currently selected text will be added to the Paint Group and will be permanently highlighted (until you clear the selection with an other editor action). So you can have different text fragments to be selected with the same Paint Group. The Paint Groups are kept when IntelliJ is closed.
You can set different colours for each Paint Group
You can set a marker to be visible on the right side of the editor
You can add multiple selections to the same group
You can convert a Paint Group to multi caret selection (and thus edit, copy, delete, etc. it)
For convenience you can undo the last addition (until the document is edited)
You can cycle through each element in a given Paint Group or in all Paint Groups
Keymap actions are added dynamically for paint, clear and convert as you add more Paint Group

Sublime Text Editor with '+' sign on the left side

Why there are plus signs on the left side of my sublime text 3 text editor on every line? How to remove it?
You have probably installed the GitGutter package. It highlights additions to your code with a + symbol, removal with a - symbol and changes with a circle.
If you don't like this feature, you can either disable (or uninstall) the entire package or use the GitGutter: Disable for View command to disable the markers for the current document.
If you don't like the appearance of those markers, you can change the styles by running the Preferences: GitGutter Popup Stylesheet command and edit the styles.

How to center text if there isn't enough newlines to get text to the center in sublime?

While coding in Sublime Text 3 if I get to the bottom of the page and try to use the show_at_center command I won't get able to get the current line all the way up to the center of the page because there isn't enough new lines. So I have to manually hit enter a bunch of times to get the text to come back up. Is there a way around this? Like some sort of command that: moves the text to the center of the screen even if there is only blank space below and no newlines.
Open your user preferences (Preferences -> Settings-User) and add the following setting:
"scroll_past_end": true
This allows you to keep scrolling the view all the way down until the last line is at the very top of the window.

PyQt QTextEdit text selection without moving the cursor (like ubuntu terminal)

I've developed a shell (imitating the ubuntu terminal --> can only edit text after current prompt) by a PyQt QTextEdit.
The thing is when I select some text, the cursor moves as I'm selecting this text (so it disappers from the current command line) and I would like the cursor to stay where it is (only when I select text because I want it to move when I move it programmatically by textEdit.moveCursor(...)) at the same time I'm selecting the text.
Does anybody have any idea of how could I do that?
My solution for now, is to save the position at any change of it (except when it changes by a click), and when I copy some text en paste it, it'll be automatically pasted in the last position the cursor was before the click. That works perfectly but it's "ugly" for the user because, as I said, when he selects the text the cursor disappears of the current line and is where the user is selecting the text. Not like in ubuntu terminal.
Thanks in advance! And sorry for my english.
Adri
I don't see an easy solution to implement this with a text editor API. A terminal is a hack, basically. It mixes a read-only element (anything above the current prompt) with a text editor.
My approach would be to create two text editors, make one read only and display the results of all operations there. If you hide the borders of the two editors, then it will look like a single one. You may have to forward a bunch of events (like scrolling with the keyboard) to the read-only display.

Resources