LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2008, 04:20 AM   #1
sanjay.krk
LQ Newbie
 
Registered: Jul 2008
Location: New Delhi
Posts: 26

Rep: Reputation: 15
Configuring mc (midnight commander) for file editing


Hi All,
I am using Fedora 7 with mc (midnight commander) as file manager.
Every time I am inside mc and I have to open a file for editing, I have to press F4 (or choose edit from menu) for opening the file.

I want to configure it such that I can open the file just by pressing "enter" after selecting the file names by arrow keys. Further I want the default editor to be vi or vim.


I will appreciate any pointers.
 
Old 09-17-2008, 05:41 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
The mc help file (press F1) shows how to turn off internal editing and specify which external editor to use.

I don't see a way to define (change) what the enter key does. Do you know that this is possible?
 
Old 09-17-2008, 08:04 AM   #3
sanjay.krk
LQ Newbie
 
Registered: Jul 2008
Location: New Delhi
Posts: 26

Original Poster
Rep: Reputation: 15
> I don't see a way to define (change) what the enter key does

I don't know. But if the file is a pdf for example, pressing enter will invoke pdfviewer by default, basically appropriate viewer for respective file formats (htmlviewer/lynx for html files) .

I am still exploring how to attach vim with regular text files.
 
Old 09-17-2008, 08:31 AM   #4
sanjay.krk
LQ Newbie
 
Registered: Jul 2008
Location: New Delhi
Posts: 26

Original Poster
Rep: Reputation: 15
I set use_internal_view=0, and set environment variable PAGER=vim.
It opens files in vim but still with F3 (and I hate it).

There has to some mechanism for files to be opened by "enter" like pdf files or directories.
 
Old 09-17-2008, 10:13 AM   #5
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
From memory to make vim the editor put:

export EDITOR=/path/bin/vim

in .bashrc or the like.
 
Old 09-17-2008, 10:16 AM   #6
sanjay.krk
LQ Newbie
 
Registered: Jul 2008
Location: New Delhi
Posts: 26

Original Poster
Rep: Reputation: 15
This only chooses external editor as vim, but "enter" still doesn't work.
Thanks.
 
Old 09-17-2008, 11:53 AM   #7
john test
Member
 
Registered: Jul 2008
Distribution: ubuntu 9.10
Posts: 527
Blog Entries: 1

Rep: Reputation: 35
Don't know if this will help but in MC under edit there is a button to edit keyboard shortcut keys that might do the job.
Question: After you redirect the enter key to call up vim, which key will you use to handle the normal Enter Key functionality?
 
Old 09-17-2008, 10:00 PM   #8
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 675

Rep: Reputation: 255Reputation: 255Reputation: 255
Take a look at the file
Code:
mc.ext
On my machine it resides in
Code:
/usr/local/share/mc
but I compiled MC from source so it could be elsewhere on your system.

For example to open .cpp files with VI the entry is:
Code:
regex/\.(C|cc|cpp)$
	Open=%var{EDITOR:vi} %f
 
Old 09-17-2008, 10:13 PM   #9
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
Enter will open the file. Which app will be used depends only on the kind of file that it is (by extension) and the configuration that you are using.

You can configure this in two ways (which are basically the same):

1.- menu Command, Edit extension file.
2.- on command line, run $EDITOR ~/.mc/bindings.

In either case, you will be editing the same file. There you can define which things you are going to be using to open each file, based on its extension. You can even use regular expressions. Just configure it to open these files in an editor, in stead of a viewer.
 
Old 09-18-2008, 05:35 AM   #10
sanjay.krk
LQ Newbie
 
Registered: Jul 2008
Location: New Delhi
Posts: 26

Original Poster
Rep: Reputation: 15
Thanks a lot, All!
Modifying the bindings file worked
I added "vi" as default (right at the bottom .
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
midnight commander file rename ques stabu Linux - Software 10 02-01-2013 09:57 PM
mc(midnight commander) - using vim to edit does not change the file on ftp rlee923 Linux - Software 2 10-18-2007 05:08 AM
how to change midnight commander file associations? Sammael Linux - Software 2 05-05-2007 10:22 AM
Midnight Commander doesn't list file(s) beginning with uppercase? sixerjman Linux - Software 0 02-14-2006 11:31 AM
midnight commander save settings makes new ini file dinges Linux - Software 0 11-25-2004 10:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration