Sublime Forum

Sublime as a replacement for my current editor

#1

Sublime obviously seems like a serious tool on par with the TextMate generation of editors. Nevertheless it still is a bit challenging to figure out how to harness all that power while the documentation and user base is still in its foundational stages.

Nevertheless, it would be nice to start using Sublime as a replacement for my current editor, even if I do not yet fully grasp all the power features. In order to do this, I wonder if someone can tell me about how to emulate these following basic features in Sublime:

  • ability to open a filepath in a text file (open file under cursor) using a keyboard combo like ctrl+shift+g
    ( see e.g., vim.wikia.com/wiki/Open_file_under_cursor)

  • ability to do “find in files” and then display the find results, and then click on one of the find results to open the corresponding line in the file

  • ability to open a file and auto-jump to a specific line number in the target file (either from command-line or using one of the above methods)

  • ability to run a perl, python, ruby, javascript … etc file and have the output result appear in a new document buffer

  • ability to highlight a word under the cursor and automatically jump to each prev-next occurence of that word using a keyboard combo

  • ability to specify what constitutes a “word” character for purposes of highlighting words upon click (e.g., include or exclude underscores and dollar signs or include them)

====
Thanks in advance for any info, and hats off on this well-respected work that is admired by those who are following its progress.

0 Likes

#2

[quote]

  • ability to do “find in files” and then display the find results, and then click on one of the find results to open the corresponding line in the file[/quote]

you can use both:

ctrl+g to specify a line number and jump to it, no command line that i know of…

if you know your way in basic python i guess it could be a breeze to set such plugin

use alt+f3, and f3 to cycle through the results. no sticky highlight yet though ( jon, please… :laughing: )

Preferences\User File Preferences, add and edit the following:
wordSeparators ./\()"’-:,.;<>~!@#$%^&*|+=]{}`~?

btw, read Preferences\Default File Preferences for a complete list of all you can change.

good luck,
vim.

0 Likes

#3

[quote]* ability to open a filepath in a text file (open file under cursor) using a keyboard combo like ctrl+shift+g

  • ability to run a perl, python, ruby, javascript … etc file and have the output result appear in a new document buffer[/quote]

These shouldn’t be that hard to code a plugin for… I think nick did the second one already…

anyways, when opening a file under cursor… how does that work?

If I have

put cursor under site.css where is it going to get the rest of the path from? the current open file? or project (if any?) ?
It shouldn’t be hard if u have the full path to it like “c:\Documents and Settings…\site\text.css”
I’ll have a go at it and see what I can do, but I bet sublimator is gonna woop my ass at writing the plugin :stuck_out_tongue: haha he’s a python beast!

0 Likes

#4

Here is some code that will run any command you want (in your case a ruby or python script) and display the results in a new buffer:

This is a modified version of some of the code from the Mercurial plugin I submitted a while ago. http://sublimetextwiki.com/pages/Mercurial.html

# Runs a system command from the command line
# Captures and returns both stdout and stderr as an array, in that respective order
def doSystemCommand(commandText):
	p = subprocess.Popen(commandText, shell=True, bufsize=1024, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	p.wait()
	stdout = p.stdout
	stderr = p.stderr
	return [stdout.read(),stderr.read()]

def displayResults(Results, view):
	if(Results[1] != None and Results[1] != ""):
		createWindowWithText(view, "An error or warning occurred:\n\n" + str(Results[1]))
	elif(Results[0] != None and Results[0] != ""):
		createWindowWithText(view, str(Results[0]))			

# Open a new buffer containing the given text			
def createWindowWithText(view, textToDisplay):
	NewView = sublime.Window.newFile(view.window())
	NewView.insert(NewView.size(), textToDisplay)

That will run any command you provide it and capture stdout and stderr. It displays stdout only if theres no output on stderr.

You should be able to take that code and roll a plugin to fit your custom needs.

1 Like

#5

[quote=“samkerr”]Here is some code that will run any command you want (in your case a ruby or python script) and display the results in a new buffer:

This is a modified version of some of the code from the Mercurial plugin I submitted a while ago. http://sublimetextwiki.com/pages/Mercurial.html

# Runs a system command from the command line
# Captures and returns both stdout and stderr as an array, in that respective order
def doSystemCommand(commandText):
	p = subprocess.Popen(commandText, shell=True, bufsize=1024, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	p.wait()
	stdout = p.stdout
	stderr = p.stderr
	return [stdout.read(),stderr.read()]

def displayResults(Results, view):
	if(Results[1] != None and Results[1] != ""):
		createWindowWithText(view, "An error or warning occurred:\n\n" + str(Results[1]))
	elif(Results[0] != None and Results[0] != ""):
		createWindowWithText(view, str(Results[0]))			

# Open a new buffer containing the given text			
def createWindowWithText(view, textToDisplay):
	NewView = sublime.Window.newFile(view.window())
	NewView .insert(NewView .size(), textToDisplay)

That will run any command you provide it and capture stdout and stderr. It displays stdout only if theres no output on stderr.

You should be able to take that code and roll a plugin to fit your custom needs.[/quote]

Very nice work sam :smile:

0 Likes

#6

Thanks!

0 Likes

#7

Hi guys

I’ve recently discovered Sublime and my first impressions are extremely favourable. I love the minimap feature plus the editor looks really cool too.

I’ve had a look through the various menu options, but something that I use a lot, but can’t find (and it doesn’t seem to work when I hold down the alt key - although I’ve tried others as well), is a column select option.

Is this feature available now (ie is it me? :confused: ) or is it on the roadmap for future releases?

Cheers,
Mick

0 Likes

#8

try alt+ctrl together with up/down arrow keys, is that what you need?

0 Likes

#9

Sort of - It seems to work vertically if I do that, but if I use the right and left arrow keys, the cursor just jumps to the next word and nothing is selected.

Visual studio and intype let you select rectangular sections of code by holding down the alt key. With ultra edit you put it into ‘column mode’ by first using alt + c then select the blocks of text

Cheers,
Mick

0 Likes

#10

well, it is a different concept here, because it is not a selection, but rather a multiplication of the cursor. imo, this far stronger, because you can edit all those places instantly, and of course mark the required characters as you like. for example, if you have a rectangular area you want to mark and replace/edit, it will look the same, but if the area is of certain structure, which is not with the same length on each line - here sublime start to shine, e.g. try and edit the following on the editors you have mentioned:

L_acc = L_deposit_l( gbk1[index1][1] ); L_accb = L_deposit_l( gbk2[index2][1] ); L_gbk12 = L_add( L_acc, L_accb ); tmp = extract_l( L_shr( L_gbk12,1 ) ); L_acc = L_mult(tmp, gcode0);

now, try and add _xyz on all functions calls… in sublime you just do the multiple cursor magic at the start of the line, going down 5 lines, now jump with ctrl+left arrow 3 times, insert _xyz - DONE!

L_acc = L_deposit_l_xyz( gbk1[index1][1] ); L_accb = L_deposit_l_xyz( gbk2[index2][1] ); L_gbk12 = L_add_xyz( L_acc, L_accb ); tmp = extract_l_xyz( L_shr( L_gbk12,1 ) ); L_acc = L_mult_xyz(tmp, gcode0);

0 Likes

#11

Thanks very much for the reply, Vim.

The way this works in Sublime is way more powerful than the ‘standard’ column or region select. I can see that this will prove extremely useful and will save me loads of time.

Cheers,
Mick

0 Likes

#12

This works perfectly except for cut/copy/paste scenarios. For example, in the following trivial example, how would I column select the numbers at the end of test and stick them at the end of line, so :

test1 line test2 line test3 line

becomes

test line1 test line2 test line3

I guess this question really is, is there a way to column-paste?

0 Likes

#13

true, for me, this is the mostly used plugin. i used it all the time with column related tasks.

0 Likes

#14

[quote=“sublimator”]There’s also this automatic column selection command

It works fairly well albeit horribly inefficiently. It’s a prototype I never finished but I use it all the time for column selection tasks. It’s also available in EJ12Ns PowerUser pack.[/quote]

yup that + pastecolumn is there too, it’s just awesome :smile:

0 Likes

#15

Aha perfect, I hadn’t spotted those plugins. Thanks guys.

0 Likes