I know subl myfile.txt:5 would open “myfile.txt” on line 5. I however want to be able to, from the command line, open a file with say lines 5,9,15 highlighted or selected. I know adding –command should enable me to do that, but how? What would the command be?
相关问题
- softlinks atime and mtime modification
- Get unexpanded argument from bash command line
- Include and Execute EXE in C# Command Line App
- Batch - Set variables in for loop
- Rails gem update not working (version 4.1.1 to 4.2
相关文章
- Compile and build with single command line Java (L
- How to update command line output?
- How to execute another python script from your scr
- Python file keyword argument?
- Interactively merge files tracked with git and unt
- Lauch default editor (like 'webbrowser' mo
- How to print jq output sequentially
- python using argparse.ArgumentParser method
There's no built-in command that I know of that can do this, but one can easily create one.
(Technically, it could be done using the bookmarks functionality from the Default package, and the built-in "Expand Selection to Line" functionality. However, experience shows that it would be better and more reliable to write a command in ST specifically for this purpose.)
In ST:
Packages/User/
) as something likeselect_lines.py
(file extension is important).subl myfile.txt
subl --command "select_specific_lines { \"lines\": [5, 9, 15] }"
(this style of escaping the quotes for JSON strings works from the Windows Command Prompt and Linux's Bash)Why did I specify the command on a separate line / call to
subl
? Because of these 2 caveats:Arguably, point 2 could still happen with multiple invocations of
subl
, but hopefully it is less likely. There is an open issue on the ST bug tracker for better command line command handling: https://github.com/SublimeTextIssues/Core/issues/1457.