## Sublime as a replacement for my current editor

### Sublime as a replacement for my current editor

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., http://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.
dreftymac

Posts: 2
Joined: Sat Jul 04, 2009 5:05 am

### Re: Sublime as a replacement for my current editor

* 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

you can use both:

* 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)

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

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

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

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

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

* 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)

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.
vim

Posts: 298
Joined: Tue May 27, 2008 6:51 pm

### Re: Sublime as a replacement for my current editor

* 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

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 haha he's a python beast!
EJ12N

Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

### Re: Sublime as a replacement for my current editor

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

Code: Select all
# Runs a system command from the command line# Captures and returns both stdout and stderr as an array, in that respective orderdef 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.
Last edited by samkerr on Thu Aug 06, 2009 5:03 pm, edited 1 time in total.
samkerr

Posts: 51
Joined: Mon Aug 03, 2009 11:20 pm

### Re: Sublime as a replacement for my current editor

samkerr wrote: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

Code: Select all
# Runs a system command from the command line# Captures and returns both stdout and stderr as an array, in that respective orderdef 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.

Very nice work sam
EJ12N

Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

### Re: Sublime as a replacement for my current editor

Thanks!
samkerr

Posts: 51
Joined: Mon Aug 03, 2009 11:20 pm

### Re: Sublime as a replacement for my current editor

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? ) or is it on the roadmap for future releases?

Cheers,
Mick
PinnacleWebDesign

Posts: 33
Joined: Sun Aug 09, 2009 6:43 pm
Location: UK

### Re: Sublime as a replacement for my current editor

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

Posts: 298
Joined: Tue May 27, 2008 6:51 pm

### Re: Sublime as a replacement for my current editor

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
PinnacleWebDesign

Posts: 33
Joined: Sun Aug 09, 2009 6:43 pm
Location: UK

### Re: Sublime as a replacement for my current editor

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:

Code: Select all
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!

Code: Select all
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);`
vim

Posts: 298
Joined: Tue May 27, 2008 6:51 pm

Next