Differences

This shows you the differences between the selected revisions of the page.

task_edit 2010-03-23 task_edit 2023-03-08 (current)
Line 1: Line 1:
====== Editing/Opening Files ====== ====== Editing/Opening Files ======
-WinSCP allows you to edit/open remote file using editor or associated application on local machine. To do so it needs to download the remote file to [[temp_folder|temporary directory]] first. Then it opens the file in your preferred editor or associated application. Once you change the file, WinSCP uploads it back. With [[ui_commander|Commander interface]] you can even edit/open local files, but most of this chapter covers editing remote files only.+WinSCP allows you to edit/open remote file using editor or associated application on local machine. To do so it needs to download the remote file to [[temp_folders|temporary directory]] first. Then it opens the file in your preferred editor or associated application. Once you change the file, WinSCP uploads it back. With [[ui_commander|Commander interface]] you can even edit/open local files, but most of this chapter covers editing remote files only.
-To edit file selected in panel go to //File(s) > Edit//. The command by default opens the file in an [[ui_editor|internal editor]]. You can make the command open the file in any external editor in [[ui_pref_editor|preferences]]. From submenu //File(s) > Edit (alternative)// you can open the file in any of configured editors, or even ad hoc editor (//Edit With//). By default the file is also opened in editor when double-clicked((If resolving of symbolic links is disabled or not possible, double-clicking file is always interpreted as attempt to enter it, just in case it is unresolved symbolic link to a directory.)) (this can be changed in [[ui_pref_panels#double-click|preferences]]).+To edit file selected in panel go to //Files > Edit//. The command by default opens the file in an [[ui_editor|internal editor]]. You can make the command open the file in any external editor in [[ui_pref_editor|preferences]]. From submenu //Files > Edit (alternative)// you can open the file in any of configured editors, or even ad hoc editor (//Edit With//). By default the file is also opened in editor when double-clicked((If resolving of symbolic links is disabled or not possible, double-clicking file is always interpreted as attempt to enter it, just in case it is unresolved symbolic link to a directory.)) (this can be changed in [[ui_pref_panels#double-click|preferences]]).
-You can create new empty file using command //File(s) > New > File//. The command asks for name of the new file and then opens your default editor. Note that you can use the command also to open an existing file by typing in its path to avoid need to navigate first to its location. +You can create new empty file using command //Files > New > File//. The command asks for name of the new file and then opens your default editor. Note that you can use the command also to open an existing file by typing in its path to avoid need to navigate first to its location. You can also open an existing file this way, or even multiple files by separating their paths with semicolon ('';'').
-To open selected file in an associated application use //File(s) > Open//. This way you do not need to configure external editor for each file type. However you will not be able to set an additional options.+To open selected file in an associated application use //Files > Open//. This way you do not need to configure external editor for each file type. However you will not be able to set an additional options.
Editing and opening of files can be [[administration|restricted by system administrator]]. Editing and opening of files can be [[administration|restricted by system administrator]].
Line 12: Line 12:
Especially when the files are opened in an external editor, user can easily change two files at once. For this reason WinSCP must upload the files back using [[transfer_queue|background transfer/queue]] to allow several uploads at once. Especially when the files are opened in an external editor, user can easily change two files at once. For this reason WinSCP must upload the files back using [[transfer_queue|background transfer/queue]] to allow several uploads at once.
-===== External Editors ===== +===== [[external_editors]] External Editors ===== 
-For basic editing WinSCP offers a simple [[ui_editor|integrated text editor]]. For advanced editing you will probably want to [[ui_pref_editor|configure your favourite editor]].+For basic editing WinSCP offers a simple [[ui_editor|integrated text editor]]. For advanced editing you will probably want to [[ui_pref_editor|configure your favorite editor]].
-==== [[mdi]] Problems with Some External Editors ==== +==== [[mdi]] Opening More Files in a Single Editor Instance ==== 
-Some external editors can open multiple files in one process. Usually such editors have some kind of tabbed interface, but it is also the case of new versions of Microsoft Word (2000 and later).+Some external editors can open multiple files in one process. Usually such editors have some kind of tabbed interface, but it is also the case of Microsoft Word.
If such an editor is already running and WinSCP runs a second instance to open a new file, then the second instance just notifies the first to open the new file and exits immediately. If such an editor is already running and WinSCP runs a second instance to open a new file, then the second instance just notifies the first to open the new file and exits immediately.
Line 22: Line 22:
To allow using this kind of editor, WinSCP does not treat the file as closed when the editor launched to open it is closed. To allow using this kind of editor, WinSCP does not treat the file as closed when the editor launched to open it is closed.
-If you choose to edit the same file again during the same session, WinSCP will download it to the same temporary directory as before, allowing the external editor to reload the file content in case it still ·has it opened (assuming the editor can detect the change).+If you choose to edit the same file again during the same session, WinSCP will download it to the same temporary directory as before, allowing the external editor to reload the file content in case it still has it opened (assuming the editor can detect the change).
-One drawback of this approach is that all of the files ever edited by the current instance of WinSCP are kept in a [[temp_folder|temporary directory]] (until WinSCP is closed). WinSCP watches for changes to them all.+One drawback of this approach is that all of the files ever edited by the current instance of WinSCP are kept in a [[temp_folders|temporary directory]] (until WinSCP is closed). WinSCP watches for changes to them all.
-If you want to avoid that, you need to make sure that your editor opens each file in a separate window (process). Some editors do that by default while some offer a configuration option for that. If either is the case, then configure your editor as an external editor for WinSCP and enable preference option //[[ui_editor_preferences#external|External editor opens each file in separate window (process)]]//. WinSCP will then treat the file as closed when the editor launched to open it is closed.  +If you want to avoid that, you need to make sure that your editor opens each file in a separate window (process). Some editors do that by default while some offer a configuration option for that (see below). If either is the case, then configure your editor as an external editor for WinSCP and enable preference option //[[ui_editor_preferences#external|External editor opens each file in separate window (process)]]//. WinSCP will then treat the file as closed when the editor launched to open it is closed. Note that this setting only affects the "edit" operation. So you may want to make sure that editing is the [[ui_pref_panels#double-click|default operation for double-click]].
-  * Note that this setting only affects the "edit" operation. So you may want to make sure that editing is the [[ui_pref_panels#double-click|default operation for double-click]]. +
-  * For configuring Vim, you would not choose to option preference above for opening each file in a separate process.  See [[task_edit#configuring_vim_as_an_external_editor|Configuring Vim as an External Editor]] for more information. +
- +
-===== Configuring Vim as an External Editor ===== +
- +
-Vim can be easily configured for use with WinSCP.  To configure Vim as an external editor in WinSCP, do the following: +
-  - From the menu of WinSCP, select //Options > Preferences// +
-  - Select //Editors// from the left pane of the //Preferences// window. +
-  - From //Editor Preference//, select //Add ...// +
-  - From the //Add Editor// window, click on the //External editor// radio button. +
-  - Click the //Browse// button and navigate to the path where Vim is installed.  For example, the default installation for a Windows installation of Vim is ''"C:\Program Files\Vim\vim72\'' (Assuming Vim 7.2 is your version).  You could also apply these steps to the portable version of Vim as well. +
-  - Select //gvim.exe// as the editor.  **(Note: This selects the GUI version of Vim.)** +
-You will notice the the box will return something that looks similar to the following:\\ **''"C:\Program Files\Vim\vim72\gvim.exe"'' !.!**\\  +
-Make sure to leave the **!.!** as it is at the end of the string.\\  +
-For simple use of Vim, choosing any of the //External editor options// below the //Editor// selection are optional depending on your needs.  However, as you will see in the next section, this is not the case for using Vim with multiple tabs.  To complete the external editor selection, click the OK button at each dialog to finish the setup. +
-Whenever you right-click on a file and select **Edit**, the file will be loaded into Vim for editing. +
- +
-==== Configuring WinSCP for Vim Multi-Tab Use ==== +
- +
-Vim supports multiple tabs as of version 7.  Invoking a multiple tab session requires an additional command line argument to be passed to Vim.  Step 6 above documents what is returned when the Vim editor executable (//gvim.exe//) is selected.  The string **''"C:\Program Files\Vim\vim72\gvim.exe"'' !.!** +
-is indicated in the box for //External editor//.  In order to enable multiple tab support, you must pass the //--remote-tab-silent// argument to the command line just before **!.!**.  To make this change, place your cursor in the drop-down box after the ''"'' and before the **!.!**.\\  +
-Just type in //--remote-tab-silent//.  Make sure there is a space between that and **!.!**.\\  +
- +
-The full command line string should look accordingly:\\  +
-''"C:\Program Files\Vim\vim72\gvim.exe" --remote-tab-silent'' !.! +
-\\  +
-In the section below titled //External editor options (affects editing remote files only)//, make sure the box titled //External Editor opens each file in separate window (process)// is **Un-Checked**.  You want each file to open in Vim in the same process since the tabs are derived in the same Vim session. +
- +
-To edit files in Vim using multiple tabs, select either one or multiple files in the WinSCP file Explorer using your mouse and keyboard.  Right click on one of the highlighted files and select **Edit**.  Vim will load the selected files in separate tabs in one Vim edit session.  Any time you want to edit an additional file in the same session, just right-click on it and select **Edit**.  The file will be loaded into a new tab in the original Vim session.\\ +
 +Learn how to select between opening files in a separate or the same window for some [[integration_editor|popular editors]].
===== [[binary]] Editing Binary Files ===== ===== [[binary]] Editing Binary Files =====
The [[ui_editor|internal editor]] supports only Windows-format text files. Thus the [[transfer_mode|text transfer mode]] is forced when transferring remote file to/from the internal editor. The [[ui_editor|internal editor]] supports only Windows-format text files. Thus the [[transfer_mode|text transfer mode]] is forced when transferring remote file to/from the internal editor.
-If you want to edit binary files you need to use [[task_edit#external_editors|external editor]] that supports binary files and uncheck preference option //[[ui_editor_preferences#external|Force text transfer mode for files edited in external editor]]//. The configured [[transfer_mode|transfer mode]] will then be used even for transfers to/from external editor. Note that if you have configured [[transfer_mode|binary transfer]] mode, your external editor must support [[transfer_mode#server-side_text_file_format|server-side format of text files]] (Unix format usually), if you still want to edit them.+If you want to edit binary files you need to use [[#external_editors|external editor]] that supports binary files (and make sure preference option //[[ui_editor_preferences#external|Force text transfer mode for files edited in external editor]]// is unchecked). The configured [[transfer_mode|transfer mode]] will then be used even for transfers to/from external editor. Note that if you have configured [[transfer_mode|binary transfer]] mode, your external editor must support [[transfer_mode#eol|server-side format of text files]] (Unix format usually), if you still want to edit them.
===== Transfer Settings when Editing Files ===== ===== Transfer Settings when Editing Files =====
Line 67: Line 39:
  * //Filename modification// option is forced to "No change".   * //Filename modification// option is forced to "No change".
  * Replacement of characters not valid on Windows is enabled (original filename is restored on upload).   * Replacement of characters not valid on Windows is enabled (original filename is restored on upload).
-  * Exclude and include masks are ignored. +  * File masks are ignored. 
-  * Text [[transfer_mode|transfer mode]] may be forced (see [[task_edit#binary|Editing Binary Files]]).+  * Text [[transfer_mode|transfer mode]] may be forced (see [[#binary|Editing Binary Files]]).
  * [[resume|Transfer resume support]] is disabled.   * [[resume|Transfer resume support]] is disabled.
 +
 +===== [[commandline]] Editing from Command-line =====
 +You can use command line parameter ''[[commandline#operations|/edit]]'' to make WinSCP open a remote file in [[ui_editor|internal editor]]. This way, you can for example create a desktop shortcut that opens a remote file as easily as a local one.
 +
 +