sublime.packages_path() broken in sublime text 3? - sublimetext2

I am developing a plugin for sublime text 2 and am now switchting to sublime text 3. It seems to me that the command sublime.packages_path() - which worked fine in sublime text 2 - is broken in sublime text 3.
When executing the following line
print('sublime.packages_path() = ' + sublime.packages_path())
in sublime text 2 I get:
sublime.packages_path() = C:\Users\Mathias\AppData\Roaming\Sublime Text 2\Packages
whereas sublime text 3 (exact same code) gives me:
sublime.packages_path() =
Does someone else have the same problem? When looking at the plugin API, it doesn't say that anything has changed. Any ideas?

Related

Sublime Text 2/3 - How to always have at least 10 lines under current line?

Is there a way to show at least x number of lines below a current line in ST? Say my cursor is on line 55, I want Sublime to display at least 10 more lines below the current line so line 55 will never be at the bottom of the screen. Is this possible in Sublime?
You can achieve this with a simple plugin, that listens for cursor movement events.
From the Tools menu in Sublime Text, click New Plugin.
Replace the contents with the following:
import sublime, sublime_plugin
class ShowLinesUnderSelectionListener(sublime_plugin.EventListener):
def show_lines_under_selection(self, view, number_of_lines_to_show):
cursor_pos = view.sel()[0].end()
row, col = view.rowcol(cursor_pos)
desired_pos = view.text_point(row + number_of_lines_to_show, col)
if not view.visible_region().contains(desired_pos):
view.show(desired_pos, False)
def on_post_text_command(self, view, command_name, args):
if command_name in ('word_highlight_click', 'move', 'move_to', 'insert'):
self.show_lines_under_selection(view, 10)
def on_post_window_command(self, window, command_name, args): # for Vintageous support
if command_name in ('press_key'):
self.show_lines_under_selection(window.active_view(), 10)
Save it to the folder it suggests as something like show_lines_under_cursor.py.
This will ensure that there are always 10 visible lines under the cursor. Note that once you reach the bottom of the file, it won't scroll any further to show 10 non-existing-in-file lines. I'm not sure if this is possible via the API.

Disable Marks Column from Sublime Text 2 Gutter

Is there a way to disable the marks column in the gutter on the left side of Sublime Text 2?
I was able to disable the fold_buttons using the following setting in the settings file:
"fold_buttons": false
In case it isn't clear, I'm talking about the whitespace reserved for the mark (dot) shown below:
Find "Settings - User" from Sublime Text 2 menus (its location depending on the platform). When you click it, it will open a new, empty or almost empty file. Here is a sample portion of it:
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"gutter": true
}
The setting you are asking for is the "gutter". Make it false and you will achieve what you asked for.
Things to note:
The curly braces at the beginning and end are important.
Each setting has a comma after it. Except the last one.

Backspace Tab in Sublime Text 2

I have block of code that I would like to move (2 space/1 tab) backwards. I know I can select the whole block and hit tab to move it forward but how do I move the whole block backwards (to the the left)?
There are two options:
Shift+ Tab
or
Ctrl+ [ (on mac this is ⌘+ [)
In Window Os Simple Press
Shift + Tab
To Remove Back Space Tab In sublime Text 2.
in linux,windows
It can be done with this command
Sublime Text,Vscode,Elipse,PhpStorm,Atom => shift+tab
Python IDLE => Ctrl + [

sublime text2 text replace pattern in all files except one or more files

I want to find and replace a particular word in all my project files except one or more files in sublime text. I am not sure how to specify that.
SO basically I want to exclude
/Uses/project_name/css/my_file.css
/Uses/project_name/css/my_file2.css
Menu: Find-> Find in Files...
Sublime is gonna open a new panel at the bottom, you just need to fill the fields.
Find: the_word_you_are_looking_for
Where: your_project_directory
Replace: the_word_that_is_going_to_replace_the_old_one
Then click on the button ... located on the right side of the field Where:, and after click in the option Add Exclude Filter; replace the -*.txt with my_file?.css or my_file*.css

How to insert a column of increasing numbers in Sublime Text 2?

text
text
text
text
after the editing, those text becomes to
1 text
2 text
3 text
4 text
It's easy in Notepad ++ with the Column Editor, but I don't know how to do the same in Sublime Text 2.
The Text Pastry plugin does the job very well. It offers the Insert Numbers Syntax.
Select multiple lines with CMD+SHIFT+L (Sublime default):
text|
text|
text|
text|
Move the cursor where you want it:
| text
| text
| text
| text
And insert numbers with Text Pastry by hitting CMD+ALT+N and entering 1 space 1 space 0:
1| text
2| text
3| text
4| text
Where 1 space 1 space 0 stands for:
Integer to start with 1
Increment by 1
Padd leading zeros 0
Replace CMD with CTRL on Windows or Linux machines.
copy of this post https://stackoverflow.com/a/64083371/5902698
You want to have a number at each row that you selected, but not the same. For exemple, you select 5 cursors and you want to write 1 2 3 4 5.
select your 5 cursors (maybe you can use the shortcut ctrl + shift + L)
ctrl + shift + P and select arithmetic
Because you have 5 cursors, it propose 1 2 3 4 5
If you want you can change your step of iteration
Or start from an other number than 1
Add even numbers
For this particular case you can use Increment Selection package. Just press Ctrl+Alt+I (Command+Control+I) while having multiple cursors at the beginning of each line.
In addition to melinath answer, here's an example of how to do it:
You will need Package Control first. It shouldn't take more than 30 seconds to install both things.
Steps:
Install Package Control.
Open Command Palette: Ctrl+Shift+P (Mac: Command+Shift+P).
Type Install Package Control and click to install.
Install Increment Selection package.
Open Command Palette again.
Type Package Control: Install Package, click on it and wait a short period.
Type Increment Selection and click on it to install.
Add line numbers to the beginning of each line.
Select all lines with Ctrl+A (Mac: Command+A)
Change selection to multiple lines with Ctrl+Shift+L (Mac: Command+Shift+L)
Go to the start of each line by pressing Home (Mac: Command+←)
Use Increment Selection with Ctrl+Alt+I (Mac: Command+Control+I)
Result:
Other examples for Increment Selection
Increment Selection can also replace numbers, prefix numbers with leading zeroes, increment letters, increment by a step and more.
[1] text [1] text [1] -> 1| text 2| text 3|
[a] text [a] text [a] -> a| text b| text c|
[01] text [01] text [01] -> 01| text 02| text 03|
[05,3] text [05,3] text [05,3] -> 05| text 08| text 11|
[5,-1] text [5,-1] text [5,-1] -> 5| text 4| text 3|
Hint: [] stands for a selection, | stands for a caret.
Featured similar plugins
Selection Evaluator: Evaluate selected mathematical expression with Ctrl+Shift+M (Mac: Command+Shift+M).
The IncrementSelection plugin enables this behavior. If you have Package Control installed, you can just search for and install it. Easy peasy!
Use Emmet package try this :
{$ text${newline}}*4
My simple workaround (up until now when I found this thread) was to go to my spreadsheet editor generate the sequence there, copy, back to subl, expand the cursor over however many lines and paste.
This approach can be applied in any text editor that allows you to expand (clone) the cursor.
You can use the plugin ConyEdit to do this, use its command line cc.abl '#1 ' to append before lines with the contents that you want.
#Nicoolasens This answer is great! Just adding one detail: On macOS you can follow these steps to put a curser at the end of each line:
Use command+A to choose all lines;
Use command+shift+L to put a
curser after each line.