narrow
narrow something.
Code navigation tool inspired by unite.vim, emacs-helm.
More information on wiki
What's this?
- Provide narrowing UI like emacs-helm and unite/denite.vim.
- Not aiming to become "can open anything from narrow-able UI" package.
- Primal focus is on code-navigation.
- Provider provide items( e.g. by
search
files in project ), you can filter items by query to narrow down further. - As you move cursor on active-editor, current item on narrow-ui is automatically synced.
- You no longer lost like "Where am I?" when you are working on multiple files.
- Let narrow navigate to next/previous item to aid your concentration.
- Edit with confidence for no-overlook by direct-edit( edit on
ag search result
on narrow-editor then apply changes to real-file ). - In mind
- keyboard navigation.
- vim-mode-plus integration( I'm also maintainer of vim-mode-plus ).
- Also see UseCase on wiki and Q&A on this doc
Roles in play.
narrow-editor
ornarrow-ui
: filter items by query and render items.narrow-provider
: Provide items to narrow.
overview
control bar
Bundled providers
You can check GIFs for all bundled provider here.
I use scan
, search
, git-diff-all
, symbols
in daily-basis, for other providers I don't use much.
scan
: Scan current editor.search
: Search byag
( you need to installag
by yourself).atom-scan
: Similar tosearch
but use Atom'satom.workspace.scan
.fold
: Provide fold-starting rows as item.git-diff-all
: Show all modified state file across project.symbols
: Provide symbols for current file.project-symbols
: Provide project-wide symbols information by readingtags
file.
Quick tour
To follow this quick-tour, you don't need custom keymap.
narrow:scan
Step1. basic by using - Open some text-editor, then via command-palette, invoke
Narrow Scan
. narrow-editor
opened, Initial items are each lines on editor. As you type, you can narrow items.- When you type
apple
as query. allapple
matching items are listed. - You can move normal
up
,down
(orj
,k
in read-only mode) key to quick-preview items. enter
to confirm. When confirmed,narrow-editor
closed.
The read-only mode is enabled by default.
narrow-editor
.
Step2. navigate from outside of - Open some text-editor, then via command-palette, invoke
Narrow Scan
. narrow-editor
opened. As you type, you can narrow items.- Click invoking editor. And see your clicked position is automatically reflected
narrow-editor
. ctrl-cmd-n
to move tonext-item
,ctrl-cmd-p
to move toprevious-item
.
- If you are vim-mode-plus user, You can use
tab
andshift-tab
.
- You can close
narrow-editor
byctrl-g
( no need to focusnarrow-editor
). - If you want to change narrow-query, you have to focus to
narrow-editor
- Use
ctrl-cmd-f
(narrow:focus
) to focusnarrow-editor
. - Use
ctrl-cmd-i
(narrow:focus-prompt
) to directly focus narrow-editor's query prompt row. - Both commands are available from outside/inside of narrow-editor.
- These navigation keymaps are available for all provider(e.g.
search
,fold
etc).
Step3. direct-edit
Direct-edit is "edit on narrow-editor
then save to real-file" feature.
Available for following providers.
scan
search
atom-scan
- Open file from project, place cursor for variable name
hello
- Then invoke
Narrow Search By Current Word
. - All
hello
matching items are shows up on narrow-editor. - If you want, you can further narrow by query.
- Then edit narrow-editor's text directly.
- Place cursor on
hello
. Thenctrl-cmd-g
(find-and-replace:select-all
), then typeworld
.
- Invoke
Narrow Ui: Update Real File
from command-palette. - DONE, changes you made on narrow-editor items are applied to real-file(and saved).
- You can undo changes by re-edit items on narrow-editor and reapply changes by
Narrow Ui: Update Real File
.
Step4. [Experimental] search keyword by mouse
- Set
Search.startByDoubleClick
totrue
from settings-view. - Double click keyword in editor.
- Each time you double click keyword, new narrow-editor open and old one is replaced.
- You can continue double click which ever narrow-editor or normal-editor.
Commands
Available in all text-editor
Other
narrow:focus
: (ctrl-cmd-f
) Focus tonarrow-editor
, if executed innarrow-editor
, it re-focus to original editor.narrow:focus-prompt
: (ctrl-cmd-i
) Focus tonarrow-editor
's query input prompt, if executed innarrow-editor
, it re-focus to original editor.narrow:refresh
: Manually refresh items innarrow-editor
.narrow:close
: (ctrl-g
) Close currently openednarrow-editor
one at a time.narrow:next-item
: (ctrl-cmd-n
) Move cursor to position of next-item.narrow:previous-item
: (ctrl-cmd-p
) Move cursor to position of previous-item.narrow:reopen
: ( no default keymap ) Reopen closed narrow editor up to 10 recent closed.narrow:query-current-word
: (ctrl-cmd-e
) Replace activenarrow-editor
's query with cursor word.narrow:previous-query-history
: (ctrl-cmd-[
) Replace activenarrow-editor
's query with previous history entry.narrow:next-query-history
: (ctrl-cmd-]
) Replace activenarrow-editor
's query with next history entry.
Invoke narrow provide
No keymaps are provided
narrow:scan
narrow:scan-by-current-word
narrow:fold
narrow:fold-by-current-word
narrow:search
: ag search. need install by your self.narrow:search-by-current-word
narrow:search-current-project
narrow:search-current-project-by-current-word
narrow:atom-scan
narrow:atom-scan-by-current-word
narrow:symbols
narrow:symbols-by-current-word
narrow:project-symbols
:narrow:project-symbols-by-current-word
:narrow:git-diff-all
Available in narrow-editor(narrow-ui)
The !vmp
followed by keymap means "which keymap is not available for vim-mode-plus user".
If you want use these keymap with vim-mode-plus
, set it by yourself.
See Wiki
core:confirm
: (enter
) Closenarrow-editor
narrow-ui:confirm-keep-open
: keep opennarrow-editor
narrow-ui:open-here
: Open item at same pane of UI's pane.narrow-ui:preview-item
: Preview currently selected item manually( you don't need in most case ).narrow-ui:preview-next-item
: (tab
) Preview next-item without moving cursor fromnarrow-editor
's query prompt.narrow-ui:preview-previous-item
: (shift-tab
) Preview next-item without moving cursor fromnarrow-editor
's query prompt.narrow-ui:toggle-auto-preview
: (ctrl-r
for non-vim-mode-plus user) Disable/enable auto-preview for thisnarrow-editor
.narrow-ui:move-to-prompt
:ctrl-cmd-i
narrow-ui:stop-insert
:escape
narrow-ui:update-real-file
: Apply changes made innarrow-editor
to real-file.( edit innarrow-editor
then save it to real file. )narrow-ui:protect
: No keymap by default, Protect narrow-editor from being destroyed bynarrow:close
(ctrl-g
).narrow-ui:exclude-file
:backspace
, Exclude items which matches filePath of currently selected item's.narrow-ui:clear-excluded-files
:ctrl-backspace
, Clear excluded files list.narrow-ui:select-files
:cmd-backspace
, interactively select which filePath's items to appear onnarrow-editor
.narrow-ui:toggle-search-whole-word
:alt-cmd-w
narrow-ui:toggle-search-ignore-case
:alt-cmd-c
narrow-ui:toggle-search-use-regex
:alt-cmd-/
narrow-ui:start-insert
:I
(!vmp
),a
(!vmp
)narrow-ui:move-to-next-file-item
:n
(!vmp
)narrow-ui:move-to-previous-file-item
:p
(!vmp
)narrow-ui:relocate
: No keymap by default, Switch location where ui opened betweencenter
workspace andbottom
dock.
Keymaps
No keymap to invoke narrow provider(e.g narrow:scan
).
Start it from command-palette or set keymap in keymap.cson
.
My keymap(vim-mode-plus user) and config
config.cson
narrow:
SelectFiles:
rememberQuery: true
confirmOnUpdateRealFile: false
keymap.cson
Explanation of my keymap.
cmd-f
: To focus to narrow-editor AND focus-back to original-editorcmd-i
: To focus to narrow-editor's prompt AND focus-back to original-editorcmd-e
:- When workspace has no
narrow-edior
on workspace: startnarrow:search-by-current-word
. - When workspace has at least one
narrow-edior
:query-current-word
( by default keymap).- Replace active
narrow-edior
's query with cursor-word.
- Replace active
- When workspace has no
cmd-[
:narrow:previous-query-history
Recall previous historycmd-]
:narrow:next-query-history
, Recall next historyctrl-g
: Closenarrow-editor
from wherever.tab
,shift-tab
: to move to next/previous item.;
: confirm current-item without closingnarrow-editor
, I can closenarrow-editor
byctrl-g
.
# From outside of narrow-editor
# -------------------------
# `cmd-e` start `search-by-current-word` only when workspace does NOT have `narrow-editor`.
# NOTE: When workspace.has-narrow, `cmd-e` is mapped to `query-current-word` by default.
'atom-workspace:not(.has-narrow) atom-text-editor.vim-mode-plus:not(.insert-mode)':
'cmd-e': 'narrow:search-by-current-word'
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'ctrl-z': 'narrow:reopen'
'space f': 'narrow:fold'
'cmd-o': 'narrow:symbols-by-current-word'
'cmd-shift-o': 'narrow:project-symbols-by-current-word'
'cmd-r': 'narrow:symbols' # Override default cmd-r
'cmd-shift-r': 'narrow:project-symbols' # Override default cmd-shift-r
'space l': 'narrow:scan'
'cmd-l': 'narrow:scan-by-current-word'
'space s': 'narrow:search'
'space G': 'narrow:git-diff-all'
# When workspace has narrow-editor
'atom-workspace.has-narrow atom-text-editor.vim-mode-plus.normal-mode':
'cmd-f': 'narrow:focus' # focus to narrow-editor
'cmd-i': 'narrow:focus-prompt' # focus to prompt of narrow-editor
# Following three command have ctrl- prefixed by default to avoid conflicts.
# But I don' care conflict, prefer more accessible keymap.
'cmd-[': 'narrow:previous-query-history'
'cmd-]': 'narrow:next-query-history'
'cmd-e': 'narrow:query-current-word'
# narrow-editor regardless of mode of vim
'atom-text-editor.narrow.narrow-editor[data-grammar="source narrow"]':
'cmd-f': 'narrow:focus'
'cmd-i': 'narrow:focus-prompt' # cmd-i to return to calling editor.
# Danger: apply change on narrow-editor to real file by `cmd-s`.
'cmd-s': 'narrow-ui:update-real-file'
# Move ui in between bottom dock and center workspace.
'cmd-t': 'narrow-ui:relocate'
'atom-workspace.has-narrow atom-text-editor.vim-mode-plus.normal-mode,
atom-workspace.has-narrow atom-text-editor.vim-mode-plus.visual-mode':
'cmd-e': 'narrow:query-current-word' # set current word as query of active ui.
'atom-text-editor.narrow.narrow-editor.vim-mode-plus.normal-mode':
'g g': 'narrow-ui:move-to-prompt'
's': 'narrow-ui:select-files'
';': 'narrow-ui:confirm-keep-open'
'n': 'narrow-ui:move-to-next-file-item'
'p': 'narrow-ui:move-to-previous-file-item'
Recommended configuration for other packages.
- Suppress autocomplete-plus's popup on narrow-editor
- Disable vim-mode-plus's highlight-search on narrow-editor
"*":
"autocomplete-plus":
suppressActivationForEditorClasses: [
# snip
"narrow"
]
# snip
"vim-mode-plus":
highlightSearchExcludeScopes: [
"narrow"
]
Notes for vim-mode-plus user
⚠️ Limitation: for compatibility with vim-mode-plus.
- If you use atom v1.16.0 or older,
- Don't enable
vim-mode-plus.automaticallyEscapeInsertModeOnActivePaneItemChange
- If you enabled, each query input on narrow-editor of
search
provider cause mode-change frominsert-mode
tonormal-mode
.
- Don't enable
- If you use atom v1.17.0 or older( currently in beta ).
- This limitation is no longer exists.
Keymap
Learn keymap available as default.
e.g. You can move to next or previous item by tab
, shift-tab
(for this to work, you need vim-mode-plus v0.81.0 or later).
Start narrow from vim-mode-plus's search-input-form
If you are vim-mode-plus user.
Following command are available from vim-mode-plus's search(/
or ?
) mini-editor.
vim-mode-plus-user:narrow:scan
vim-mode-plus-user:narrow:search
vim-mode-plus-user:narrow:search-current-project
vim-mode-plus-user:narrow:atom-scan
How to edit item-area for direct-edit.
- In narrow-editor,
i
,a
innormal-mode
move cursor to prompt line. - So when you want to edit items itself for
direct-edit
andupdate-real-file
use other key to enterinsert-mode
. I
is intentionally mapped tovim-mode-plus:activate-insert-mode
which is normally mapped toi
.- Which might not be intuitive, but I want make item mutatation bit difficult. So user have to type
I
.
- Which might not be intuitive, but I want make item mutatation bit difficult. So user have to type
- Other than
I
, you can startinsert-mode
byA
,c
etc..
Q&A
What providers are you seriously using?
In daily editing, I use.
scan
, search
, git-diff-all
, symbols
.
Why I'm not using others? reason is here.
fold
: Since it similar tosymbols
.atom-scan
: it is provided for windows user who can't usesearch
(needag
orrg
).
narrow-editor
by normal cmd-w
(core:close
). Why I need narrow:close
? What's the difference?
Noticed I can close The biggest difference is narrow:close
restore editor state(scrollTop, fold, active pane item) if user did only preview
from startup.
narrow:close
: Closenarrow-editor
and restore editor state when it appropriate. Also can closenarrow-editor
regardless of current active-editor.core:close
: Just destroynarrow-editor
.
Use whichever you want accordingly.
I normally use narrow:close
and occasionally use core:close
such like when I want to focus next-pane-item of narrow-editor
(so don't want to restore focus to narrow initiated editor).
narrow:search
How can I exclude particular file from backspace
on item
Use - Use
backspace
to exclude particular file from result. ctrl-backspace
clear excluded file list and refresh- These keymaps are available in
narrow-editor
and you are inread-only-mode
select-files
provider
Use - You can launch
select-files
bycmd-backspace
or clickingfolder-icon
on control-bar.
- search
editor
bynarrow:search
, you see lots ofeditor
mached items - But you want exclude items in markdown file?
- launch
select-files
, all file paths are listed as item. - Then type
md
on query, you see markdown filepath that macheedmd
. - Then add
!
, now your query ismd!
, this is treated as all files not matchingmd
. enter
to confirm.
- You see items with items in markdown files are excluded.
- You can re-fine files to exclude by re-launching
select-files
.
- e.g. To exclude
spec
folder, you can addspec/!
as query. - e.g. To include
.js
file only, you can set query to.js
.
next-file
, previous-file
Want to skip to - Use
n
,p
inread-only
mode.
narrow:symbols
always shows up at right-most pane and don't want to close.
I want - Open
narrow:symbols
( or maybe you want to usenarrow:fold
) - Move this
narrow-editor
by drag and drop to the place where you want. - From command-palette, execute
Narrow Ui: Protect
. Nownarrow-editor
protected. - Protected
narrow-editor
is not closed byctrl-g
(narrow:close
), and not closed by confirm byenter
. - To close, use normal
cmd-w
or close button on tab.