Author Topic: Macro to change file Browser to location of current buffer  (Read 4566 times)

jrocnuck

  • Junior Community Member
  • Posts: 2
  • Hero Points: 1
Macro to change file Browser to location of current buffer
« on: October 05, 2011, 08:07:31 PM »
I connect this simple macro to a keyboard shortcut (CTRL-D) in my case.
I have the Open File window set up to not automatically switch directories when I select new file windows.
When I have a bunch of files open and switch to back and forth from open files but want to switch the Open File window to the directory where the file lives, I run the macro.

Code: [Select]
#region Imports
#include "slick.sh"
#import "dir.e"
#import "dirlist.e"
#endregion

_command cd_to_file_location() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
    _str directory;
    if (_mdi.p_child.p_window_id && _mdi.p_child.p_buf_name != '' && file_exists(_mdi.p_child.p_buf_name) ) {
        directory = strip_filename(_mdi.p_child.p_buf_name, 'NE');
        _dlSetPath(directory,true);
    }
}

lclevesy

  • Guest
Re: Macro to change file Browser to location of current buffer
« Reply #1 on: October 06, 2011, 01:53:47 PM »
@jrocnuck Thank you for your submission. It is in the running for the iPad!

The winner will be announced via our Facebook page https://www.facebook.com/slickedit, Twitter page http://www.twitter.com/slickedit, and on this forum under the main SlickEdit October Macros Challenge Rules & How to Enter post http://community.slickedit.com/index.php/topic,7327.0.html on November 7, 2011.

lclevesy

  • Guest
Re: Macro to change file Browser to location of current buffer
« Reply #2 on: November 01, 2011, 03:15:33 PM »
We'll be announcing the winner of the iPad 2 on November 7th. Until then, your submission has earned a SlickEdit t-shirt! Email your size and address to marketing@slickedit.com to receive one.