Does anyone know of a shortcut for jumping to a specific line (given a #) in Sublime Text?
Ex: I run code and get an error at line 5765. I want to be able to jump quickly in Sublime Text to line 5765, without scrolling.
Windows: Ctrl + G
Mac: Control + G
Linux:Ctrl + G
or
Windows: Ctrl + P + :
Mac: Command + P + :
Linux: Ctrl + P + :
Then type the line number. It will automatically find it for you and if it requires scrolling to get to - it will snap your view to the line number level.
Rather than Control+G, if you're used to using CMD+P or CMD+T, you can just type :
Also useful:
CMD+R go to function in current file
CMD+Shift+R find function in any file (CMD+, "binary_file_patterns" ignore node_modules)
CMD+Option+Down jump to function definition in another file (from cursor word)
CMD+D / CMD+U jump & accumulate next word occurrence & populate search query / (undo). from cursor becomes an exact match (case and word boundary) vs from selection is a partial match (ignore case and word boundary). D and U also work in less bash / zshell pager to scroll down / up half pages
CMD+G / CMD+Shift+G jump or "go" to next / previous search query (CMD+D amazing with this)
CMD+{ / CMD+} focuses left / right tab (same in terminals, browser, kapeli dash, etc.)
CMD+[ / CMD+] shift line left / right (chrome forward / backward nav, devtools changes panel)
CMD+Control+Up / CMD+Control+Down shift line up / down
CMD+K->(some number) fold to indentation
CMD+K->J unfold all
CMD+Option+[ / CMD+Option+] fold / unfold current line's children
CMD+, is preferences in most all Mac applications
As pointed out by #maxTuzz, I use Ubuntu 16.06 and Sublime regularly,
this Ctrl+P then Pressing : and Starting typing the Line Number you want to Navigate.
Or
Directly we can type Ctrl+G Starting typing the Line Number you want to Navigate.
In My Mac, Performance>>Key Bindings add:
//line duplicate & delete
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+d"], "command": "duplicate_line" },
//replace
{ "keys": ["super+r"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
//goto
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["super+g"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },
//upper or lower
{ "keys": ["super+shift+u"], "command": "swap_case" },
//sidebar toggle
{ "keys": ["super+shift+t"], "command": "toggle_side_bar" },
base is to press Ctrl + P and a then type : and then write the line that you want to go , BUT there is a shortcut for this :
Just hit Ctrl + G , and it does the same steps for you!
on your keyboard click the:
command + p
then type : on your keyboard follow by the line number, example 374
:374
then click the enter key on your keyboard to jump to the desired line number
Related
Introduction
Hi! I'm trying to extract JSon from a 300K line text file that has a combination of Text output and JSon format from HTTP Result. The big size in lines makes it unable to retain the JSon manually.
Problematic
Don't have much choice, i probably need to fix it manually using a command-line. Here's how it's looks like inside the file:
[2K 100.00% - C: 164148 / 164149 - S: 263 - F: 3686 - dhcp-140-247-148-215.fas.harvard.edu:443 - id3.sshws.me
[2K 100.00% - C: 164149 / 164149 - S: 263 - F: 3686 - public-1300503051.cos.ap-shanghai.myqcloud.com:443 - id3.sshws.me
[2K
[
{
"Request": {
"ProxyHost": "pro.ant.design",
"ProxyPort": 443,
"Bug": "pro.ant.design",
"Method": "HEAD",
"Target": "id3.sshws.me",
"Payload": "GET wss://pro.ant.design/ HTTP/1.1[crlf]Host: [host][crlf]Upgrade: websocket[crlf][crlf]"
},
"ResponseLine": [
"HTTP/1.1 101 Switching Protocol",
"Server: cloudflare"
]
},
{
"Request": {
"ProxyHost": "industrialtech.ft.com",
"ProxyPort": 443,
"Bug": "industrialtech.ft.com",
"Method": "HEAD",
"Target": "id3.sshws.me",
"Payload": "GET wss://industrialtech.ft.com/ HTTP/1.1[crlf]Host: [host][crlf]Upgrade: websocket[crlf][crlf]"
},
"ResponseLine": [
"HTTP/1.1 101 Switching Protocol",
"Server: cloudflare"
]
}
]
Several problem to this if using RegEx is:
It has multiple JSon object
The Text string that doesn't part of JSon has [ and :
I realize the problem when trying to use sed regex.
sed '/^[/,/^]/!d'
You can remove all lines that start with [ and any non-whitespace char:
sed '/^\[[^[:space:]]/d' file > newfile
Details:
^ - start of a line
\[ - [ char
[^[:space:]] - any non-whitespace chars.
Alternate way to this is; to get advantage for special char. If someone wanted to remove the progress bar from the output and extract only appropiate output:
Use nano <output_file>
You will see that there's new line unicode got readed as ^M^[ in the first text. I assume it's the same as [crlf]
Use sed -e "/\^M^[/d" remove lines that contains specific unicode.
Use \ to escape ^ as RegEx.
Make sure to always find the pattern readed from the terminal and not inside a text editor app, as some of them couldn't read Unicodes.
I'm currently trying to set the debugging startup arguments for a CMake based project in Visual Studio Community 2017. Normally this would be done via the launch.vs.json file. However, the arguments that I need to pass contain spaces in them. For example, the below launch.vs.json file should pass the arguemnts FIRST ARGUMENT and SECOND ARGUMENT as the first and second argument. However, the program ends up getting 4 arguments: FIRST, ARGUMENT, SECOND, and ARGUMENT. I've tried various different encodings for spaces, but cannot get a space to be encoded properly in the resulting arguments. This is especially problematic as one of the arguments to my program is a path inside C:\Program Files. As such, the path is broken into 2 separate arguments, rather than one as it should be. How do I make Visual Studio allow spaces within an argument?
For reference, launching via the command line with this command works as expected:
argtest.exe "FIRST ARGUMENT" "SECOND ARGUMENT"
launch.vs.json
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "argtest.exe",
"name": "argtest.exe",
"args": ["FIRST ARGUMENT", "SECOND ARGUMENT"]
}
]
}
test.c
#include <stdio.h>
int main(int argc, char ** argv) {
int i;
for (i = 0; i < argc; i++)
printf("%d = %s\n", i, argv[i]);
return 0;
}
CMakeLists.txt
cmake_minimum_required (VERSION 2.8.8)
project (argtest)
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/ )
add_executable(argtest test.c)
You need to include the quotes in the args strings and escape them. For example:
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "argtest.exe",
"name": "argtest.exe",
"args": ["\"FIRST ARGUMENT\"", "\"SECOND ARGUMENT\""]
}
]
}
It is easier doing this through Visual Studio itself. To run a program with command-line arguments follow these steps:
Open the project in Visual Studio
Click on the 'Debug' tab in the menu bar.
Click on the '[NAME OF PROJECT] Properties' menu item.
A window will popup and should automatically go into the Debug menu within that window. Under the 'Start options' section enter your command-line arguments with a space between each argument.
Hope this helps.
I know there are at least 2 other questions like this on SO but none of those answers are working for me.
I'm trying to customize my user settings on Sublime Text 2 (mac) but when I go to save it I get the error listed below.
Here are my settings.
{
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"default_encoding": "UTF-8 with BOM",
"font_size": 15,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages": [
"Vintage"
],
"line_padding_bottom": 4,
"line_padding_top": 0,
"wide_caret": true
}
Here's the error:
Error trying to parse settings: Expected value in ~/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings:1:1
The answers listed on Sublime Text 2: Error trying to parse settings and on Error trying to parse settings do not help at all.
Sublime text 2 (Windows 7) has such feature: several lines with carets (no selections made,only carets) are copied to Clipboard separated with empty lines. Can i disable these empty line separators, to copy w/o them?
detail:
open few lines text file
place 3-4 carets using Ctrl+Click on few lines
press Ctrl+C to copy to clibboard
paste into new file-- u see empty line separators for copied text
Think you need a plugin to do it. I didn't test this, but it should work. It's pretty straight forward.
import sublime
import sublime_plugin
class EmptyLineCopyCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
lines = []
for cursor in view.sel():
lines.append(view.substr(view.line(cursor)))
sublime.set_clipboard("\n".join(lines))
Put the following in your user key bindings.
{"keys": ["ctrl+c"], "command": "empty_line_copy", "context": [
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
]},
I am working on a big display with high resolution, thus I work in multiple groups/panes as it is more productive (imho). I switch tabs using ctrl + tab and groups/panes using ctrl + 1 to 9. I want to 'lock' the ctrl + tab to current group/pane so it would not select tabs in another panes.
I really want that functionality but can't think of a way to achieve this. Is it possible to do this?
You can use a simple plugin to do it.
import sublime
import sublime_plugin
class ChangeViewCommand(sublime_plugin.WindowCommand):
def run(self, reverse=False):
window = self.window
group, view_index = window.get_view_index(window.active_view())
if view_index >= 0:
views = window.views_in_group(group)
if reverse:
if view_index == 0:
view_index = len(views)
if reverse:
new_index = view_index - 1
else:
new_index = (view_index + 1) % len(views)
window.focus_view(views[new_index])
Then add the following to your user key bindings.
{ "keys": ["ctrl+tab"], "command": "change_view" },
{ "keys": ["ctrl+shift+tab"], "command": "change_view", "args": { "reverse": true } }
For focus group, there are already commands to go to groups 1 - 4, but you can add the following to go further (simply change the key binding number and group number)
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } }