[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: insert name of current file
From: |
Deniz Dogan |
Subject: |
Re: insert name of current file |
Date: |
Tue, 25 Jan 2011 23:10:05 +0100 |
2011/1/25 Gradivus <mondifero@gmail.com>:
>
> Hi,
>
> Sorry I'm a noob.
>
You're excused!
> I wonder if someone knows how I can insert the current file's name
> (i.e., the name of the file I'm editing) at the cursor, and without the full
> path.
>
As far as I know, there is no such functionality by default, but put
this in your init file to bind "C-c i f" to it:
(defun insert-buffer-file-name ()
"Inserts the name of the file for the current buffer."
(interactive)
(if buffer-file-name
(insert (file-name-nondirectory buffer-file-name))
(message "No file associated with buffer.")))
(global-set-key (kbd "C-c i f") 'insert-buffer-file-name)
Hope that helps,
Deniz Dogan