How do I change drive letter in ido mode (Emacs)? - emacs

I'm using Emacs on windows. My default folder is c:/home, but I want to edit my file in d:/ how to do it in ido mode ? I tried // but that put me in c:/.
Currently, I use C-f (change back to normal find file mode), but that defeat the purpose of using ido mode in first place....

As stated in a comment you just type "d:/" in the minibuffer while in ido-find-file. You don't need to be at the start of the string, it's intelligent enough to know what you're trying to do.
C-x C-f d:/ MyFile.txt
will point you at the file D:/MyFile.txt

Related

Shell script mode automatically at each emacs start

Each time when I edit bash script I type a command M-x shell-script-mode. And then I get nice shell code higlighting. How to get it automatically each time I start emacs so I do not have to type the command. When I added (shell-script-mode) to init.el it did not help.
You can set the default major mode to be whatever you want by adding
(setq-default major-mode 'shell-script-mode)
to your init file. That will ensure that any newly created buffer will be in shell-script-mode unless its mode is specified otherwise (e.g. through auto-mode-alist). Whether it's a good idea or not, I don't know: I probably would not want that to be my default setting - but to each her/his own.
One of the simplest ways to have Emacs set the desired mode for a buffer editing a file is to include a special comment in the first line of that file, e.g. for a shell script your first line might be:
# -*-sh-*-
For scripts it is also common, or and often even required, to have an interpreter file comment on the very first line of the file, which of course would preclude having an Emacs mode comment, so Emacs also looks for interpreter file comments and associates those with a major mode, so the first line of your shell script might be:
#!/bin/sh
There are a number of other ways to tell Emacs how to set the buffer mode when visiting a file. See, for example, Emacs Manual: Choosing File Modes

Emacs Tramp - add proposed paths to TRAMP

I use the following method to connect to a remote host via emacs TRAMP :
C-x C-f /remotehost:filename RET (or /method:user#remotehost:filename)
It works great, and remotehost can be one of my ssh aliases. However I still have to navigate the whole path for the filename, which can be quite long.
Is there a way to set up a default path (like a default cd) that would be pre-filled/proposed in the list (if existing for instance) when opening a new TRAMP/ssh connection to a particular host ?
Example :
C-x C-f /work-host:/
;; auto complete suggests some files, how do I suggest another file/path ?
Note : I am using Emacs prelude in case it matters
You might navigate to your complete path, open a dired buffer, then save that as a bookmark (C-x r m). The next time you want to go there, just use the bookmark (C-x r b).
The Tramp manual explains in its FAQ section several ways to shorten paths. It's not exactly what you have asked for, but maybe it gives you some imagination what could be done.
Eval (info "(tramp) Frequently Asked Questions")

Emacs Dired - C-x C-f to create a new file gives me suggestions of existing files

I'm trying to create a file in dired mode in emacs. I am in the right directory and when I press C-x C-f as suggested elsewhere on SO and type 'img' (that's the name of the file I want to create), it tries to find existing files from other directories including the pattern 'img'. Then I'm stuck as if I press enter, it'll open the first suggested file containing the pattern 'img' from other directories, TAB will just go over the suggestions.
Please advise.
You are probably using ido-find-file with which you can interactively select a file by typing a substring of that file name.
If you want to temporarily disable this feature (i.e. for your current search only) just press C-f before typing the name of your new file (i.e. immediatly after C-x C-f).

Comparing local and server files from emacs

I am a new user to emacs. I need to compare two files, one local file and another in a server.
I fireup emacs opening my local file. Now I split emacs into two using C-x 3. Now I opened up a shell in my second frame on the right. I opened a shell using M-x shell. Now ssh-ed into my server. I navigated to a deep location and I need to open a file from this location on my right buffer. I tried C-x C-f but its showing my location directory?
Is there a solution for this?
Edit:
I think I stressed my problem wrongly. I just want to see both files open in emacs and read them together. Not really a diff.
Use Tramp and ediff. Something like
M-x ediff-files RET
/local/path/to/file RET
/ssh:user#host:/remote/path/to/file RET
user and host are the arguments you need for ssh.

Opening multiple files at once in Emacs

In Emacs using ido-mode allows me to open a file from the minibuffer with C-xC-f. This method opens only one file at a time.
How do I open all the files in a directory or specify more than one file to open?
You can just provide * as the file name and press Enter; you'll be asked for a confirmation and if you press Enter a second time, all files in the directory will be opened.
Note that "opening all files in a directory" involves opening dired buffers for all of its subdirectories.
When not using ido-mode -- at the basic Emacs find-file prompt -- you can use the same * to open all files in a directory. When you do use ido-mode to find files, you can always press C-f to drop back to the usual Emacs find-file prompt. (You can use ido to speed up getting to some directory you're interested in first and drop to the basic find-file in there.) That's one way of creating a new file with ido (the other being the C-j binding); also, it gives you another way of using the above mentioned * trick.
File-name groking is nowhere near as useful as more general pattern-matching.
In Icicles file-name completion, you can open any number of files matching any number of patterns, from the same minibuffer. Pattern-matching can be substring, regexp, fuzzy, or prefix, and you can combine patterns using intersection and complementing.
Just as in Ido, in Icicles your minibuffer input dynamically filters the file-name candidates. You can choose individual candidates or choose all that currently match (using C-!).
(You can of course use file-name groking also. As with Emacs file-name input generally, hitting RET on a wildcard (grok) pattern sends it to find-file, which opens all matching files.)