summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/actions.py11
-rw-r--r--ranger/commands.py13
2 files changed, 21 insertions, 3 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index a881f7c2..6aab4581 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -20,6 +20,7 @@ from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
 from ranger.gui.widgets import console_mode as cmode
 from ranger.applications import run
+from ranger.fsobject import File
 
 class Actions(EnvironmentAware, SettingsAware):
 	search_method = 'ctime'
@@ -242,11 +243,15 @@ class Actions(EnvironmentAware, SettingsAware):
 	def execute_command(self, cmd, **kw):
 		return run(fm=self, action=cmd, **kw)
 	
-	def edit_file(self):
+	def edit_file(self, file=None):
 		"""Calls execute_file with the current file and app='editor'"""
-		if self.env.cf is None:
+		if file is None:
+			file = self.env.cf
+		elif isinstance(file, str):
+			file = File(os.path.expanduser(file))
+		if file is None:
 			return
-		self.execute_file(self.env.cf, app = 'editor')
+		self.execute_file(file, app = 'editor')
 
 	def open_console(self, mode=':', string=''):
 		"""Open the console if the current UI supports that"""
diff --git a/ranger/commands.py b/ranger/commands.py
index a62caf60..411408eb 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -271,6 +271,18 @@ class mkdir(Command):
 			pass
 
 
+class edit(Command):
+	"""
+	:edit <filename>
+
+	Opens the specified file in vim
+	"""
+
+	def execute(self):
+		line = parse(self.line)
+		self.fm.edit_file(line.rest(1))
+
+
 class rename(Command):
 	"""
 	:rename <newname>
@@ -371,6 +383,7 @@ def alias(**kw):
 		by_name[key] = value
 
 alias(q=quit)
+alias(e=quit)
 
 def command_generator(start):
 	return (cmd + ' ' for cmd in by_name if cmd.startswith(start))