Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30ad82671b | ||
|
|
59cafd6b99 | ||
|
|
ef4bb8a6ac | ||
|
|
744ec7351e | ||
|
|
23dde8c7ee | ||
|
|
a887128b9f | ||
|
|
a33959f829 | ||
|
|
b9b3ba3e9f | ||
|
|
15038d7b0c | ||
|
|
2b7e6346a5 | ||
|
|
4f1ebf8a1a |
5 changed files with 64 additions and 25 deletions
|
|
@ -1,5 +1,7 @@
|
|||
## (unpublished)
|
||||
|
||||
* Fix `:enew` not working ([#215](https://github.com/lloeki/ex-mode/pull/215))
|
||||
|
||||
## 0.18.0
|
||||
|
||||
* Add Gdefault support ([#191](https://github.com/lloeki/ex-mode/pull/191))
|
||||
|
|
|
|||
29
README.md
Normal file → Executable file
29
README.md
Normal file → Executable file
|
|
@ -30,7 +30,34 @@ atom.packages.onDidActivatePackage (pack) ->
|
|||
Ex.registerAlias 'Wq', 'wq'
|
||||
```
|
||||
|
||||
See `lib/ex.coffee` for some examples commands. Contributions are very welcome!
|
||||
## Existing commands
|
||||
|
||||
This is the baseline list of commands supported in `ex-mode`.
|
||||
|
||||
| Command | Operation |
|
||||
| --------------------------------------- | ---------------------------------- |
|
||||
| `q/quit/tabc/tabclose` | Close active tab |
|
||||
| `qall/quitall` | Close all tabs |
|
||||
| `tabe/tabedit/tabnew` | Open new tab |
|
||||
| `e/edit/tabe/tabedit/tabnew <file>` | Edit given file |
|
||||
| `tabn/tabnext` | Go to next tab |
|
||||
| `tabp/tabprevious` | Go to previous tab |
|
||||
| `tabo/tabonly` | Close other tabs |
|
||||
| `w/write` | Save active tab |
|
||||
| `w/write/saveas <file>` | Save as |
|
||||
| `wall/wa` | Save all tabs |
|
||||
| `sp/split` | Split window |
|
||||
| `sp/split <file>` | Open file in split window |
|
||||
| `s/substitute` | Substitute regular expression in active line |
|
||||
| `vsp/vsplit` | Vertical split window |
|
||||
| `vsp/vsplit <file>` | Open file in vertical split window |
|
||||
| `delete` | Cut active line |
|
||||
| `yank` | Copy active line |
|
||||
| `set <options>` | Set options |
|
||||
| `sort` | Sort all lines in file |
|
||||
| `sort <line range>` | Sort lines in line range |
|
||||
|
||||
See `lib/ex.coffee` for the implementations of these commands. Contributions are very welcome!
|
||||
|
||||
## Status
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,6 @@
|
|||
':': 'ex-mode:open'
|
||||
'atom-text-editor.ex-mode-editor':
|
||||
'ctrl-c': 'ex-mode:close'
|
||||
'ctrl-[': 'ex-mode:close'
|
||||
'atom-text-editor.vim-mode:not(.insert-mode)':
|
||||
':': 'ex-mode:open'
|
||||
|
|
|
|||
|
|
@ -55,3 +55,8 @@ module.exports = ExMode =
|
|||
description: 'When on, the ":substitute" flag \'g\' is default on'
|
||||
type: 'boolean'
|
||||
default: 'false'
|
||||
onlyCloseBuffers:
|
||||
title: 'Only close buffers'
|
||||
description: 'When on, quitall only closes all buffers, not entire Atom instance'
|
||||
type: 'boolean'
|
||||
default: 'false'
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ CommandError = require './command-error'
|
|||
fs = require 'fs-plus'
|
||||
VimOption = require './vim-option'
|
||||
_ = require 'underscore-plus'
|
||||
atom
|
||||
|
||||
defer = () ->
|
||||
deferred = {}
|
||||
|
|
@ -132,7 +133,11 @@ class Ex
|
|||
atom.workspace.getActivePane().destroyActiveItem()
|
||||
|
||||
quitall: ->
|
||||
if !atom.config.get('ex-mode.onlyCloseBuffers')
|
||||
atom.close()
|
||||
else
|
||||
atom.workspace.getTextEditors().forEach (editor) ->
|
||||
editor.destroy()
|
||||
|
||||
q: => @quit()
|
||||
|
||||
|
|
@ -206,9 +211,7 @@ class Ex
|
|||
e: (args) => @edit(args)
|
||||
|
||||
enew: ->
|
||||
buffer = atom.workspace.getActiveTextEditor().buffer
|
||||
buffer.setPath(undefined)
|
||||
buffer.load()
|
||||
atom.workspace.open()
|
||||
|
||||
write: ({ range, args, editor, saveas }) ->
|
||||
saveas ?= false
|
||||
|
|
@ -226,29 +229,30 @@ class Ex
|
|||
deferred = defer()
|
||||
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
saved = false
|
||||
|
||||
# Case 1; path is provided
|
||||
if filePath.length isnt 0
|
||||
fullPath = getFullPath(filePath)
|
||||
if editor.getPath()? and (not fullPath? or editor.getPath() == fullPath)
|
||||
if saveas
|
||||
throw new CommandError("Argument required")
|
||||
else
|
||||
# Use editor.save when no path is given or the path to the file is given
|
||||
trySave(-> editor.save()).then(deferred.resolve)
|
||||
saved = true
|
||||
else if not fullPath?
|
||||
fullPath = atom.showSaveDialogSync()
|
||||
fullPath = getFullPath filePath
|
||||
|
||||
# Only write when it does not exist or we have a force flag set.
|
||||
if force or not fs.existsSync(fullPath)
|
||||
editor.saveAs(fullPath)
|
||||
return deferred.promise
|
||||
|
||||
if not saved and fullPath?
|
||||
if not force and fs.existsSync(fullPath)
|
||||
throw new CommandError("File exists (add ! to override)")
|
||||
if saveas or editor.getFileName() == null
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
trySave(-> editor.saveAs(fullPath, editor)).then(deferred.resolve)
|
||||
else
|
||||
trySave(-> saveAs(fullPath, editor)).then(deferred.resolve)
|
||||
|
||||
deferred.promise
|
||||
# Case 2; no path provided, call editor save.
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
|
||||
# Does the current buffer exist?
|
||||
if editor.getPath()? and fs.existsSync(editor.getPath())
|
||||
trySave(-> editor.save()).then(deferred.promise)
|
||||
else
|
||||
# Cant see what the better API is but Pane.saveActiveItemAs() is the only call
|
||||
# I could find that states it will ask the user.
|
||||
trySave(-> atom.workspace.getActivePane().saveActiveItemAs()).then(deferred.promise)
|
||||
|
||||
return deferred.promise
|
||||
|
||||
wall: ->
|
||||
atom.workspace.saveAll()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue