How to make Sublime Text open several files in one window? - sublimetext3

Using Sublime Text 3 on the Centos 7.6 (Linux) operating system.
When I use Sublime Text to open files from the command prompt:
[root#localhost www]# sublime sitemap.php
[root#localhost www]# sublime robots.txt
The files are opened in 2 Sublime Text windows, even when the open_files_in_new_window setting is set to false.
How do I make Sublime Text open the files in one window?

I also use a Linux distribution and when I open files from the command line they do open in the same window.
The command you are using on the command line is sublime I suspect that starts Sublime Text with the --new-window option.
Look to see if you have the /usr/bin/subl file on your system. If you do then use subl instead of sublime on the command line and see if that opens the files in the same window.
If /usr/bin/subl is not on your system then you can create it like this:
Note: /usr/bin/subl is just the Sublime Text launcher which is automatically installed on Debian based Linux distributions.
Add these 2 lines to a new file and save it as /home/user/subl:
Note: Change the path to /opt/sublime_text/sublime_text if need be.
#!/bin/sh
exec /opt/sublime_text/sublime_text "$#"
Then run these commands as a super user or with sudo, whatever is easiest with Centos:
$ chown root:root subl
$ mv subl /usr/bin/
Now you should be able to use subl on the command line to open files in Sublime Text and they should open in the same window, e.g.:
$ subl sitemap.php
$ subl robots.txt

Related

Opening up files with sublime text 3 in git bash in Windows

I want to open files with Sublime text 3. Is there a way that I can permanently set Sublime text as the default editor in git bash?
I tried the following code:
alias 'subl= "/c/Program Files/Sublime Text 3/subl.exe"'
and it worked. But, when I closed the Git bash and reopen it later, the command subl didn't work and I had to type in the code again.

Nautilus: Open with Vim

I'm using arch linux with gnome and I try to open text files with vim by using nautilus. I already created a vim.desktop file in my .local/share/applications folder .
If I choose Vim in Nautilus, nothing happens. My default terminal doesn't work and I already tried to change my default terminal to terminator, but it didn't work. Maybe there is an other option to change the .desktop file to forcing nautilus to open a new terminator window with vim. I guess I need to change the exec parameter.
This should work
[Desktop Entry]
Name=VIM
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=vim %f
Type=Application
Terminal=true
Categories=Development;TextEditor;
Keywords=Text;Editor;

Ansible vault doesn't save changes with Sublime Text

I'm running ansible 1.9.4 on OSX installed via pip.
If I do ansible-vault create x, then make some changes and save, then the file appears blank whenever I do ansible-vault view x or ansible-vault edit x.
I've got Sublime Text 3 as my $EDITOR. When I set it to vim instead, it all works as expected, and I can edit and save my files encrypted with ansible-vault. Any idea what could be happening here?
I don't think it'll work with the standard Sublime command line launcher. ansible-vault waits for the editor process to exit before encrypting the temp file it creates- the Sublime launcher exits immediately, so you end up with an empty vault file.
EDIT:
To make it work with the standard Sublime command line launcher, you have to specify the -w flag, which will stop the subl process from existing until the file is closed in sublime text. (see docs)
So your .bashrc should have a line like this:
export EDITOR='subl -w'

terminal command for running sublime text 3 from on ubuntu

I've installed a new dev machine using Ubuntu 14.02. I have also installed all the relevant software. php/apache2/sublime/composer etc.
I'd like to be able to open files with a sublime or subl command in the terminal, but can't seem to find the command to point things correctly.
My sublime executable resides here...
/opt/sublime_text/sublime_text
in /usr/bin/subl I have the command
#!/bin/sh
exec /opt/sublime_text/sublime_text "$#"
I just can't find the command in the terminal to make it happen. The sublime documentation points to mac instructions, but I'm too newby to translate.
Any suggestions?
$# in a shell script basically copies all arguments given to the shell script (after the name of the script) and places them at that point during execution of the script.
For example,
if you were to run subl test.txt, it would be as though you are running exec /opt/sublime_text/sublime_text "test.txt".
Now, /opt/sublime_text/sublime_text --help or subl --help gives us help text which shows the usage as well.
Sublime Text build 3065
Usage: sublime_text [arguments] [files] edit the given files
or: sublime_text [arguments] [directories] open the given directories
Arguments:
--project <project>: Load the given project
--command <command>: Run the given command
-n or --new-window: Open a new window
-a or --add: Add folders to the current window
-w or --wait: Wait for the files to be closed before returning
-b or --background: Don't activate the application
-h or --help: Show help (this message) and exit
-v or --version: Show version and exit
Filenames may be given a :line or :line:column suffix to open at a specific
location.
If you pass more than one parameter, then all of them are also treated the same. So, if you ran subl file1.txt file2.cpp file3.html then it'd open all 3 of those files.
As per Mathias comment in my question I found the answer here...
How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window

Start Sublime 3 from terminal, when default is Sublime Text 2

I am on Ubuntu 12.04 LTS. Calling sublime foo.txt would normally open foo.txt in Sublime Text 2. Recently I installed Sublime Text 3. In addition to this, I tried to remove Sublime Text 2 completely from my filesystem.
After doing this, my system still tries to open Sublime Text 2 when I use sublime in my terminal. Clearly this is no good - because I removed Sublime Text 2. (at least partially).
I noticed the Sublime Text 2 icon is still in my applications list. If I try to remove it by clicking Uninstall I get the following error:
The files which should be removed are not part of any installed software.
So how do I fully remove it from an Ubuntu system, and how do I make sublime open Sublime Text 3?
Type : subl in terminal to launch Sublime Text 3 from terminal.
sudo ln -s /opt/sublime_text/sublime_text /usr/bin/sublime
When you run sublime, your computer should run a bash file at /usr/bin/sublime (running which sublime as Mike Li suggested will confirm the location. Open that up and edit it for Sublime Text 3. The contents of that file should be:
#!/bin/bash
/usr/lib/sublime-text-2/sublime_text --class=sublime-text-2 "$#"
Edit it as so: (On my computer the executable is called subime_text_3 instead of subime_text. Verifiy by opening /usr/lib/sublime-text-3.)
#!/bin/bash
/usr/lib/sublime-text-3/sublime_text_3 --class=sublime-text-3 "$#"
Point it to the location of Sublime Text 3 on your system.
Edit Build 2221 (using the ppa) changed the installation directory from /usr/lib/sublime-text-2 to /opt/sublime_text_2
No need to do extra configuration for this. Just use subl commnad and it will open the sublime text editor.
For sublimetext 3, it is only need "subl"

Resources