is it possible to nmap two consecutive commands to the same pane in vifm? - vifm

I would like to create an nmap that would first cd to a particular directory and then edit a file in that directory. For instance, this would allow me to open a LaTeX file and edit it, but then exit from that file and be in the directory to pull up the pdf file that LaTeX created. I have tried the following:
nmap b :cd /path/to/directory/ <cr> :edit file.tex
This almost works and will suffice if it is the only way to do it. What happens is that the left pane changes to the correct directory and the file is opened in the right pane. Then when I quit I only need to move between panes to get to the other files. However, it would be simpler/cleaner if I could get both commands to happen in the same pane.
Is this possible?
Thanks

The reason why two commands happen in different panes is that RHS of your mapping contains a space in normal mode (right after <cr>). You should either remove it or don't switch between modes at all by performing two commands in a row (which should be separated by a bar/pipe):
nnoremap b :cd /path/to/directory/ | edit file.tex<cr>

Related

Keyboard short for uploading two files in PhpStorm

The problem
In PhpStorm I have a style.css- and a app.js-file that I have to upload to a server over and over again. I'm trying to automate it.
They're compiled by Webpack, so they are generated/compiled. Which means that I can't simply use the 'Tools' >> 'Deployment' >> 'Upload to...' (since that file isn't and won't every be open).
What I currently do
At the moment, every time I want to see the changed I've done, then I do this (for each file):
Navigate to the files in the file-tree (using the mouse)
Select it
The I've set up a shortcut for Main menu >> Tools >> Deployment >> Upload to..., where-after I select the server I want to upload to.
I do this approximately 100+ times per day.
The ideal solution
The ideal solution would be, that if I pressed a shortcut like CMD + Option + Shift + G
That it then uploaded a selection of files (a scope?) to a predefined remote server.
Solution attempts
Open and upload.
Changing to those files (using CMD + p) and then uploading them (once they're open). But the files are generated, which means that it takes PhpStorm a couple of seconds to render the content (which is necessary before I can do anything with the file) - so that's not faster.
Macro.
Recording a macro, uploading the two files, looking like this:
If I go to the menu and trigger the Macro, then it works. So far so good.
But if I assign a shortcut key and trigger that shortcut while in a file, then it shows me this:
And if I press '1' (for it to upload to number 1 on the list), then it uploads the file that I'm currently in(!?), and not the two files from my macro.
I've tried several different shortcuts (to rule out some kind of keyboard-shortcut-clash):
CMD + Option + CTRL + 0
CMD + Shift 0
CMD + ;
... Same result.
And the PhpStorm Macro's doesn't seem to give me that many options anyways.
Keyboard Maestro.
I've tried doing it using Keyboard Maestro.
But I can't get it setup right. Because if it can't find the folders (if they're off-screen or if I'm in a different project and forgot to adjust they shortcuts), then it blasts through the rest of the recorded actions, resulting in chaos. Ideally it should stop, if it can't find the file on the screen.
Update1 - External program
Even if it's not possible to do in PhpStorm, - are there then another program that I could achieve this with?
Update2 - Automatic Deployment in PhpStorm
I've previously used this, - but I've had happen a few times that I started sync'ing waaaay to many files, overwriting critical core files. It seems smart, but can possibly tear down walls if I've forgotten to define an ignore properly.
I wish there was an 'Automatic Deployment for theses files'-function.
Update3 - File Watchers
I looked into file-watchers ( recommendation from #LazyOne ). Based on this forum thread, then file watchers cannot be used to upload files.
It is possible to accomplish it using external program scp (Secure Copy Protocol):
Steps:
1. Create a Scope (for compiled files app.js and style.css)
2. Create a Custom File Watcher with scp over that Scope
Start with Scope:
Create a Local Scope with name scp files for your compiled files directory (I will assume that your webpack compiles into dist directory):
Then, to add dist directory into Scope, select that folder and click on Include Recursively. Apply and Move to File Watchers
Create a custom template for File Watcher:
Choose a Name
Choose File type as Any
Choose Scope as scp files(created earlier)
Choose Program as scp
Choose Arguments as $FileName$ REMOTE_USER#REMOTE_HOST:/REMOTE_DIR_PATH/$FileName$
Choose Working directory as $FileDir$
That's it, basically what we have done is every time when a file in that scope changes, that file is copied with scp to the remote server to the corresponding path.
Voila. Apply Everything and recompile your project and you will see that everything is uploaded to the server.
(I assumed that you have already set up your ssh client; Generated public/private keys; Added a public key in your remote server; And, know ssh credentials to connect to your remote server)
I figured this out myself. I posted the answer here.
The two questions are kind of similar but not identical.
This way I found is also not the best, since it stores the server password in clean text. So I'll leave the question open, in case someone can come up with a better way to achieve this.

Is there a way to open a file in split view from recent files popup

I have this Recent files popup:
I can open any file from it by pressing ENTER. Is there any way to open the file in a split view? I have tab limit set to 1, so opening a file from Recent files and then opening it in a split view replaces the currently open file. I'd like to open a file in a split view without replacing the current tab. Maybe key mapping somehow?
Unfortunately not (as far as my knowledge goes).
https://youtrack.jetbrains.com/issue/IDEA-108556 -- watch this and related tickets (star/vote/comment) to get notified on any progress.
The only other possible options (generally speaking):
Shift + Enter to open it in a new/detached editor.
Open as usual and then use Move Down or Move Right to move it in that split group (will create if you do not have one). But this will NOT work if you set to have only 1 editor tab max.
Open as usual, clone it to bottom/right side (so it opens in both splitters) and then re-open recently closed file in one of the split areas again (yeah .. long and inconvenient).
Move focus to another splitter before invoking Recent Files (if you have no such splitter yet -- create one for current file). Now chose file as usual -- it will replace file in current splitter (inconvenient as you need to think about correct location in advance instead of quickly opening the needed file).

How do I configure fpp (Facebook Path Picker) to open new tabs in macvim using a vimer alias?

I believe that I need to set the $FPP_EDITOR environment variable to be able to change the default editor that fpp would invoke when opening files.
I have aliased mvim to vimer -t with alias mvim="vimer -t". This means that the mvim command should open new files in the currently available (operating system level) macvim window, and even if a sequence of files is included, it should open them in new tabs in that (operating system level) window. So if I already have an instance of macvim running and I try to pass in 4 files, I now have one window with 5 tabs in it.
But when I try to use mvim as the editor (with export FPP_EDITOR="mvim"), it opens the files in new macvim (operating system level) window, in separate (vim buffer level) windows in a single tab. So if I already have an instance of macvim running and I try to pass in 4 files, I now have two macvim "instances" running in separate OS-level windows, one with 1 tab with 1 buffer-level window, and one with 1 tab with 4 buffer-level windows.
It seems like FPP must be doing more than just passing in files in a sequence as a suffix to the $FPP_EDITOR command. I'm not sure what that is, nor exactly how to figure it out.
This is an answer to the question (technically) that I figured out as I was writing out the question.
But, it's missing all the right extra info about what was going wrong, so I'm going to this as an answer, but will happily accept another answer that can do more than just answer the question per se, but can give some background info about why the aliasing only sorta works.
The key though (if you just want a solution) is to use
export FPP_EDITOR="vimer -t"
and this performs as desired. For some reason it does not seem that setting the environment variable to a command that is aliased uses the aliased command, if it has an available original meaning (which mvim does).

SublimeText3 open header/source

I use sublimetext3 to program C++.
I use multiple window splits with multiple files open.
Sometimes I use alt+o hotkey / switch_file command to open the associated header/source file.
If I hit switch_file command and the matching header/source is already open in the same sub window split, it will jump to that tab instead of reopening the file.
But if I have a header open in one sub window split, and the source open in another sub window split, and I do switch_file command, it will open another copy of the file in the currently focused window.
Is there a way that I can set it to jump to the file even if it needs to focus another window split?
Thanks
I think the easiest way to establish this is to change the switch_file command.
Install PackageResourceViewer and type PackageResourceViewer: Open Resource, select Default and then open switch_file.
In line 41 just change
self.window.open_file(new_path, flags = sublime.FORCE_GROUP)
to
self.window.open_file(new_path)
and save the file. This will not overwrite the existing file (which is in a zip folder), but create a file, which shadows the original file.

Sublime text 2 - Zip open files with full path name and dir structure

Is there a plugin or a macro, that creates a tar ball or a zip of all opened files / tabs in Sublime Text 2.
If not, how to make a plugin that does that?
I was checking the API of Sublime Text 2, only to know that there is no method that gets the full path of all open files.
However, I see that we have an option when we right click in any file - "Copy file path".
Which method it calls? Can I replicate the method to all tabs switching one by one? If yes, then how to cycle through open tabs one by one using the API?
You can use window#views to get all the views (as a list). Then iterate on each view and use view#file_name to get the files. As for creating zips, take a look at the zipfile library.
For your particular case, I would create a window command. You can then bind that to a key combination or add it as a command palette entry. Finally, to set the visible view, you can use window#focus_view. You may also need window#focus_group if you have multiple groups.