How to start GVim on Windows with vimfiles at custom location? - windows

I am using Cygwin most of the time with my vimfiles on /usr/share/vim8/ and my runtimefiles at %HOME%\.vim.
I installed GVim for Windows and I would like to use the Vim files from Cygwin. When I start GVim it cannot find the runtimefiles. How can I configure it?
It does find my .vimrc tough.

If you want to share the configuration between Vim in Cygwin and native GVim, you could create a NTFS symlink from the Cygwin $HOME/vim directory to the Windows %HOMEPATH% directory. I use the same set of configuration files for Vim regardless of whether it’s running on a GNU/Linux system, Cygwin or native Windows. Here’s the Windows command that I used to create my NTFS symlink (with Windows 7, the mklink command must be run in a command window with elevated privileges).
mklink /D %HOMEPATH%\vimfiles C:\cygwin64\home\anthony\.vim
Also, instead of using _vimrc (MS Windows)or ~/.vimrc (Unix-like) for the primary vimrc, I use $HOME/.vim/vimrc. With the above symlink, this will automatically be found (and used) by GVim as $HOME/vimfiles/vimrc.
For configuration settings that only apply in a Windows environment, you can include a configuration block in your vimrc similar to the following:
if has("win32") || has("win64")
set guifont=Consolas:h10:cANSI
" Other Windows-specific configurations, e.g., key mappings
source $VIM\_vimrc
endif

Related

How to use Cygwin version of find rather than Windows version

I have got Cygwin installed in my machine and set its bin folder in my PATH.
I can use all the Cygwin commands in the Windows command prompt.
However, one problem I encountered is that both Cygwin an Windows have a command "find". Whenever I use find, the Windows version is picked up.
Is there anyway I can force using the Cygwin version of find rather than the Windows version?
Make sure the the cygwin executables folder /usr/bin is ahead of the cmd executables folder c:\Windows\system32 in the PATH variable for both the cmd and bash shells to be sure you run cygwin's find instead of windows's find command.
Use which -a find in the cygwin shell to list executable files found via the bash shell's PATH variable.
Use where $PATH:find in cmd shell to list executable files found via the cmd shell's PATH variable.
This is because find is a shell built-in in cmd, so it doesn't even try to go through the executable search path.
In general Cygwin symlinks will not be understood by Windows, but as explained https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks it is possible in modern Windows versions to create native Windows symlinks on NTFS file systems, as long as the link doesn't cross file systems.
I would consider instead just wrapping it in, say, a batch script placed in your Cygwin /usr/local/bin with a name like cygfind.bat (or whatever you want to call it) that explicitly calls Cygwin's find by C:\path\to\find.exe.
The wrapper approach has the advantage that if you upgrade Cygwin and find is updated, the batch script wrapping it will still work transparently.
I've never tried it myself but according to this answer you can also use the special #doskey variable to override cmd builtins.

How can I open a cygwin terminal?

I'm using a windows 8 and have cygwin installed. However, when I navigate to the folder it's contained in, the only subfolders are usr and var, and neither contains something that looks like a terminal. How can I open a cygwin terminal?
You should use mintty executable for this. In case of a default install path it is located here: c:\cygwin\bin\mintty.exe
Cygwin installation puts a shortcut to the start menu, but perhaps this feature was broken in win8.
I checked this shortcut on my computer, and it contains this command as a "Target":
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
You should create a shortcut like this. Replace the given path, if your cygwin is located anywhere else. -i command line argument is not necessary. For further info check the manual page of mintty, which is located here.
You can run
c:\program files\cygwin\bin\bash.exe
inside the Windows CMD.
When you install cygwin, it normally installs a ".bat" file at the top of the directory-tree containing cygwin, which can run a command-window. For example:
#echo off
C:
chdir C:\cygwin64\bin
bash --login -i
The exact location of the cygwin tree is relevant to the script, of course, and details change occasionally. But the bash executable, starting in cygwin's bin-directory is enough to start a window.
Outside cygwin, you will not see things such as mounted directories and symbolic links. So (from the Windows file explorer) it may look incomplete.

Set system path for CMD on Windows 8.1: Trying to override Windows/System32/find.exe

I'm trying to override the windows find command, so that I can call another implementation of find. The other implementation is provided by MSYS and located in C:\MinGW\msys\1.0\bin. On Windows 7, I can open up a CMD, and run:
SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
Since that prefixes the MSYS path before the C:\Windows\System32\ path, when find is called within CMD on Windows 7, the MSYS version executes.
That command doesn't work with Windows 8.1. When I call find in CMD on Windows 8.1, it defaults to the Windows implementation no matter what I do. Is there a way to override it on Windows 8.1?
I'm looking for a solution that only changes the path information of the current CMD instance. For my purposes, I'd rather not have to use powershell (even though the path setting works as expected in powershell).
Thanks!
When you run cmd.exe, make sure that you are not running the command from the C:\Windows\System32 directory (that's where it opens automatically for me). When you are in a directory with a matching command (in this case MS' find.exe) that local copy will take precedence over your PATH variable, even if your MSYS find.exe is listed first in the path.
So, to get it to work for me I run cmd.exe, then
C:\WINDOWS\system32>SET PATH=C:\msys64\usr\bin;C:\Program Files (x86)\CodeBlocks\MinGW\bin;%PATH%
If I run where find I get
C:\WINDOWS\system32>where find
C:\Windows\System32\find.exe
C:\msys64\usr\bin\find.exe
C:\Program Files (x86)\Git\bin\find.exe
If I change directories and run where find I get:
C:\WINDOWS\system32>cd C:\
C:\>where find
C:\msys64\usr\bin\find.exe
C:\Windows\System32\find.exe
C:\Program Files (x86)\Git\bin\find.exe
My path is slightly different because I'm trying this with MSYS2, but the same should apply to the older version of MSYS.
Good luck #mikewesthad!

emacs 24 on windows 7, tramp cannot find plink program

I am trying to use Emacs 24.2 with Tramp on windows 7 to remotely edit files on a linux server. I installed the Putty suit program and OpenSSH. I also placed the plink.exe in the putty suit into the bin folder under the emacs 24 folder, and added the folder emacs24/bin into the PATH environment variable.
However, when I try to access the remote file from emacs with the command in the minibuffer: /username#host:filename, I get the following error message from emacs: plink is not recognized as an internal or external command. It seems that emacs cannot find the plink program. But, when I try to run plink in windows cmd, it can find the plink program. Also, I can ssh to the remote server in windows cmd.
Can anyone tell me what's my problem? Do I need to install cygwin to make it work? Thanks a lot.
To get tramp with plink to work, I had to add my PuTTY path to my system search path.
On Windows 10:
control panel >> System & Security >> System >> advanced system settings >> enviroment variables
To PATH I appended the PuTTY path: C:\Program Files (x86)\PuTTY
I'm guessing the key is that from PowerShell or the command prompt, you need to be able to run plink without specifying the path.
I was able to resolve this and I did not have to install cygwin.
Try adding the path where putty was installed to your exec-path variable in emacs. Execute the following elisp code in emacs or put it in your .emacs file. Make sure the slashes are forward, not backslashes, as Emacs and Windows use different conventions.
(add-to-list 'exec-path "C:/Program Files (x86)/PuTTy")
check what exec-path is set to by typing C-h v exec-path

What file explorer can I use in Cygwin with UNIX like paths?

I'm fed up with using Windows Explorer as my file browser as I use
Cygwin bash as my primary command line environment.
Windows Explorer shows the full path in the address bar.
Usually, I copy that, pasting it to the cygwin command prompt as in
cygpath ""
I then copy paste the output of cygpath so I can
cd to it. I've also set up cpath "Bash Shell Here"
but this only works on right clicking directories.
I've used WinSCP via SSH.
ie. Start an SSH daemon in cygwin and connect to it via WinSCP.
What file explorer can I use in Cygwin with UNIX like paths?
Is there a cygwin X Windows file explorer?
Have you tried Midnight Commander (mc)? It's in the Cygwin package repository.
If you surround the path from Windows Explorer with single or double quotes, there is no need to use the cygpath command.
In regard to your quest for a compatible file manager, I've heard that KDE's Konqueror runs on Windows.

Resources