Opening files into an existing vim session (Cygwin/mintty) - windows

I am looking for ideas to open files into an existing vim session.
I am working on Windows + Cygwin + Mintty. I usually have 3 to 4 opened terminals (2-3 vim sessions + 1 shell, build environment). I don't use tmux/screen because it's easier to use the native Windows's window manager to switch in between my terminal windows. Because I have 2 wide-screen monitors I can use the 2 half of both screens for my terminals which gives me an awesome working environment. With the help of an AHK script, I can use shortcuts to switch/rotate or even to reposition my terminals in the desired position.
I rather prefer vim over gvim for many reasons. I can achieve almost all the gvim features (scroll, mouse selection, copy, paste, etc. I am one of those who think that using the respectable y/P commands is a bit crippling when you need to use plenty of other softwares that use /. I always get confused to use different shortcuts for each software I am using.
Now the core issue. I would like to open a file from the Windows explorer into an existing vim session. I found a horrible solution using a Perl script with the Win32::API in order to look for an existing mintty terminal with Vim in the title. Then I activate the window and send <esc>:e path/file<cr> to it.
It works pretty well but I am looking for a better solution like gvim --remote that works with my console vim. Unfortunately I don't have such options with my vim even though if I built it with the -with-x configure option.
So, I am looking for some suggestions to achieve a more honorable solution (socket/adding the feature directly to vim/using a smarter ahk script/etc.)

gvim --remote should work with console vim if you start vim with vim --servername GVIM. Alternatively, choose another servername and use vim --servername foo --remote.

Related

Using windows shortcuts in vim

I was wondering if there was a way to use windows shortcuts in vim (in particular those used to select lines (with shift, alt, ctrl) ?
Maybe an option to set in the .vimrc ?
Thanks.
You can enable this via the following command in your ~/.vimrc:
source $VIMRUNTIME/mswin.vim
See :help mswin.vim for a detailed explanation.
Alternatively, copy that script into ~/.vim/plugin/mswin.vim. This allows you to gradually comment out or tweak certain mappings. The downside of this plugin is that many Windows shortcuts conflict with Vim commands, so you're losing some features, and the completely different structure may prevent you from learning and using Vim effectively. Having started with a Windows background myself, this is how I proceeded. Now, I only use a few of those Windows mappings in Vim, and have customized several remaining ones so that they provide a true added value.

Run terminal inside vim on a macbook?

I searched some old answers on stackoverflow, some of them seem relevant, but none of the solutions work on my macbook (with mountain lion). e.g. The shortcuts mentioned in answers here do not work on my computer: How do I run a terminal inside of Vim?
So I'm wondering if it's because vim on mac/unix is different from a normal linux one. I don't think so, but I'm not sure.
Since I can split the screen with :sp, I'm wondering if it's possible to use one split as terminal and another as the regular vim editor, just like emacs. If so, what's the correct way to do it? (Maybe particularly for mac) If not, it's sad.
Why don't you do things the other way around?
You can use a terminal multiplexer such as Tmux and split a terminal window into two panes using C-b %.
Inside the second pane you can run macvim inside a terminal with $ mvim -v
You can navigate between the two panes with C-b o, (And do much more, but I'll leave it up to you to discover!)
Doing things this way around is much more sane in my opinion, you get the full power of both the terminal and vim without having to hack around with Vim too much (Plus Tmux is very handy for many other uses).
I hope doing things this way around is appealing enough for you!
Having a terminal inside of vim would go against the author's philosophy and design so no: that feature will probably never appear nativelyly in vim.
There are a couple of plugins that more or less work like conqueterm, try them if you really want that feature. Or simply use a separate terminal window like everybody.
You should definitely look at programs like tmux or screen.
But an even simpler solution is to use C-z (which halt vim) to access the terminal and fg to bring back vim into the foreground.

Terminal window inside Sublime Text 2

I saw this project that basically opens a new terminal window from sublime text-2.
What I'm looking for is a way to open the terminal inside sublime text 2 via console.
Does anyone knows how can I do that?
SublimeREPL does what you want
https://github.com/wuub/SublimeREPL/
Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.
+ 2 years (sorry) - but my solution in ubuntu was to open both sublime and my (real) terminal in the same window, shrink and stretch the terminal to cover the lower portion of the screen, then right click on the terminal and select "keep on top" - works a treat.
EDIT 04/23/2019: Terminus extends TerminalView & adds:
Windows support
Continuous history
Easily customizable themes (see Terminus Utilities)
Unicode support
256 colors support
Better xterm support
Terminal panel view
imgcat support (also works on Linux / WSL)
Bind key shortcut to open shell on file path (e.g. ctrl+alt+t to open):
{
"keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
"cwd": "${file_path:${folder}}"
}
}
Original Answer:
I've tried pretty much every terminal package around, what you want is TerminalView:
To bind a key shortcut, simply add it to your user key bindings file:
{ "keys": ["ctrl+alt+t"], "command": "terminal_view_open" },
Use Glue. It is a plugin that provides an interface to your shell from the Sublime Text. So basically it a terminal for Sublime Text.
https://packagecontrol.io/packages/Glue
Like #mikko I also decided that due to the limitations of the shell add-ons for sublime to stick with a real terminal window - I've got too used to the F2-F4 workflow of geany.
So really the issue for me is quickly flip-flopping between the two windows easily. To that end, I knocked this up - to be fired from F12 (or whatever you want) in your desktop manager (XFCE in my case)
Note, I launch sublime a from shortcut with terminator -T st3_bash & st3 so I've got a known bash window title for switching focus to.
https://gist.github.com/robertpearce/8725224
I know this code is really, (really) bad, and it'll fail if you have multiple sublime's open, but i don't ever have that anyhow.
Feel free to fork and improve it.
I have always wanted a way to open terminal inside sublime text. After trying out different options I have come to a solution of installing guake terminal as a work around on linux systems, follow the steps below.
Run the command sudo apt-get install guake
Press F12 (for opening terminal)
Now you can use the terminal without leaving sublime.
For windows :
Install Conemu
Have the Quake settings as shown in the pic below
Press ctrl + ~ (for opening terminal)
Note: This is just a workaround. Guake is basically a terminal package for ubuntu-like linux systems.

New OSX User: Opening up a new terminal window in current space(?)

I'm just meddling with OSX after a few years on Linux. There's a lot that I'm liking, but one thing that's slowing me down is that if I run the 'terminal' command via shortcut/spotlight/quicksilver, it whisks me off to any existing terminal in whatever space already has a terminal instance open.
I regularly like to pop up a terminal, run a quick command and then close it again, all the while staying in whatever desktop space I happen to be on.
...So, how do I do that on Mac?
Cheers...
Go to System Preferences -> Exposé & Spaces -> Spaces and check When switching to an application, switch to...
Download this tool called Visor
It lets you quickly get a tabbed drop down terminal using a hotkey like Ctrl-`.
Insanely convenient for working in the shell.
Try this tool: https://github.com/nmadhok/OpenInTerminal
This is a really handy tool for programmers on Mac as it lets you open the folder directly in Terminal. You can select multiple folders to open them in multiple terminal windows. You can also select files to open the parent directory in Terminal. This application works with Finder as well as without Finder which is a plus!

Better windows command line shells [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Is there a better windows command line shell other than cmd which has better copy paste between Windows' windows and console windows?
Enable QuickEdit mode, under the Options tab of your shortcut to the command shell. Mark with the mouse, right-click to copy, right-click again to paste.
While you're there, enable a hotkey (like CTRL + ALT + C) for lightning fast access to the shell.
And no, you can't have CTRL + C for COPY, because CTRL + C means BREAK.
On a related note, the Microsoftee who changed the default setting of QuickEdit mode between Windows Server 2000 and 2003 is an idiot and I heap curses upon him each workday.
Windows PowerShell is the obvious choice when it comes to "better windows command line shell other than cmd". Its clipboard handling isn't that much of an improvement - mark with the mouse, Enter to copy, or right mouse click to paste.
This probably is not exactly what you want, but you can take a look at Console2
I have it configured so that shift+select auto copies and middle click pastes, really handy, internally it uses same old cmd.exe so you are not really getting a different shell.
By the way, I guess Ctrl+C = copy is not the best idea in a command line context because it usually means interrupt running process.
Take Command does support Copy/Cut/Paste from the keyboard and the mouse. It's pretty handy if you do a lot of work from a command prompt. It also supports:
Command and folder history, with popup windows to select prior commands or folders.
Screen scroll back buffer
Enhanced batch commands
Built in FTP/HTTP file access
A toolbar with programmable buttons
Note: It's a paid tool, with price of $99.95.
Depending on what you're trying to do with the shell, rxvt in cygwin is good.
You'll get the nicety of auto copy on selection and middle click paste. The biggest downside is that some windows console apps don't play nice with cygwin.
PowerCmd is cheaper than TakeCommand and has a lot of powerful features - not the least of which is better handling of Cut/Copy/Paste. I've only been using it a short time but I'm really impressed so far:
Summary from the site:
PowerCmd enhances your command prompt
with an easy-to-use Windows GUI-style
interface and allows you to run
multiple consoles within a single
tabbed window. You can easily organize
multiple consoles in vertical,
horizontal, and grid forms. Auto-log,
auto-completion, keywords highlight,
configurable font and colors,
customizable toolbar for frequently
used commands or tools and minimizing
to tray are easy solutions to daily
needs. With PowerCmd, you can save and
restore your sessions from last time.
Site:
http://www.powercmd.com/
Features:
http://www.powercmd.com/features.php
Not sure what specifically you mean by better copy/paste but try Take Command.
Take Command supports Shift+Ins for paste and Shift+Del for cut, but apparently nothing for copy, will dig some more.
There are two portion to cmd.exe. First there is the window that pops up for dealing with the text console. I would replace that with ConEmu. That program is actually meant as a wrapper for the Far File manager but works just fine without it. It is very similar to Console2 but also is much more stable and has better features.
Second there is the command line interpreter. I would replace that with Powershell if you actually need any of its features.
I currently run using ConEmu with a batch file to setup my preferred environment. This is kept in my Dropbox folder so it remains synchronized between my computers.
Have you thought through what behavior you want to replace the current Ctrl+C functionality?
Console 2
http://sourceforge.net/projects/console/
http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx
#Chirs
I think you need to clarify shell vs host(emulator). To me it sounds like you need another interface to your existing shell that better supports copy and paste, not another shell that supports more/different features.
I second Pat's suggestion of Console2, it is a very good application and OSS to boot.
The Windows cmd shell, Cygwin Bash, and msysgit Bash shells can be run within Emacs. EmacsW32 provides all three separately. You just have to set the bin directory to use either of the Bash shells. EmacsW32 also provides limited interactions between the Windows clipboard and the top item of the kill ring.
MinGW Shell properly set up with:
right click menu entry
~/.profile file
is well above anything else I have tried.
MinTTY on MinGW/MSYS is nice—nicer than on Cygwin because MinGW/MSYS is faster. Also, if you need cmd.exe behaviour, you can run cmd.exe inside of mintty easily.
See http://code.google.com/p/mintty/.
I use the standard CMD.EXE shell but with a twist: an AutoHotKey script to support clipboard copy-paste as posted in: Keyboard shortcut to paste clipboard content into command prompt window (Win XP)

Resources