This package provides the following services:
This package consumes the following services:
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
searchfiles 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 resulton 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-editorornarrow-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 installagby yourself).atom-scan: Similar tosearchbut 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 readingtagsfile.
Quick tour
To follow this quick-tour, you don't need custom keymap.
Step1. basic by using narrow:scan
- Open some text-editor, then via command-palette, invoke
Narrow Scan. narrow-editoropened, Initial items are each lines on editor. As you type, you can narrow items.- When you type
appleas query. allapplematching items are listed. - You can move normal
up,down(orj,kin read-only mode) key to quick-preview items. enterto confirm. When confirmed,narrow-editorclosed.
The read-only mode is enabled by default.
Step2. navigate from outside of narrow-editor.
- Open some text-editor, then via command-palette, invoke
Narrow Scan. narrow-editoropened. As you type, you can narrow items.- Click invoking editor. And see your clicked position is automatically reflected
narrow-editor. ctrl-cmd-nto move tonext-item,ctrl-cmd-pto move toprevious-item.
- If you are vim-mode-plus user, You can use
tabandshift-tab.
- You can close
narrow-editorbyctrl-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,foldetc).
Step3. direct-edit
Direct-edit is "edit on narrow-editor then save to real-file" feature.
Available for following providers.
scansearchatom-scan
⚠️ This operation is dangerous, since you can update multiple files at once. ⚠️ You have to be careful enough to use this feature, don't use this without understanding what you are doing. ⚠️ I can say sorry, but I can not recover file for you.
- Open file from project, place cursor for variable name
hello - Then invoke
Narrow Search By Current Word. - All
hellomatching 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 Filefrom 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.startByDoubleClicktotruefrom 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-editorone 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:scannarrow:scan-by-current-wordnarrow:foldnarrow:fold-by-current-wordnarrow:search: ag search. need install by your self.narrow:search-by-current-wordnarrow:search-current-projectnarrow:search-current-project-by-current-wordnarrow:atom-scannarrow:atom-scan-by-current-wordnarrow:symbolsnarrow:symbols-by-current-wordnarrow: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-editornarrow-ui:confirm-keep-open: keep opennarrow-editornarrow-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-rfor non-vim-mode-plus user) Disable/enable auto-preview for thisnarrow-editor.narrow-ui:move-to-prompt:ctrl-cmd-inarrow-ui:stop-insert:escapenarrow-ui:update-real-file: Apply changes made innarrow-editorto real-file.( edit innarrow-editorthen 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-wnarrow-ui:toggle-search-ignore-case:alt-cmd-cnarrow-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 betweencenterworkspace andbottomdock.
Keymaps
No keymap to invoke narrow provider(e.g narrow:scan).
Start it from command-palette or set keymap in keymap.cson.
⚠️ default keymap is not yet settled, this will likely to change in future version.
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-edioron 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-historyRecall previous historycmd-]:narrow:next-query-history, Recall next historyctrl-g: Closenarrow-editorfrom wherever.tab,shift-tab: to move to next/previous item.;: confirm current-item without closingnarrow-editor, I can closenarrow-editorbyctrl-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
searchprovider cause mode-change frominsert-modetonormal-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:scanvim-mode-plus-user:narrow:searchvim-mode-plus-user:narrow:search-current-projectvim-mode-plus-user:narrow:atom-scan
How to edit item-area for direct-edit.
- In narrow-editor,
i,ainnormal-modemove cursor to prompt line. - So when you want to edit items itself for
direct-editandupdate-real-fileuse other key to enterinsert-mode. Iis intentionally mapped tovim-mode-plus:activate-insert-modewhich 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-modebyA,cetc..
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(needagorrg).
Noticed I can close narrow-editor by normal cmd-w(core:close). Why I need narrow:close? What's the difference?
The biggest difference is narrow:close restore editor state(scrollTop, fold, active pane item) if user did only preview from startup.
narrow:close: Closenarrow-editorand restore editor state when it appropriate. Also can closenarrow-editorregardless 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).
How can I exclude particular file from narrow:search
Use backspace on item
- Use
backspaceto exclude particular file from result. ctrl-backspaceclear excluded file list and refresh- These keymaps are available in
narrow-editorand you are inread-only-mode
Use select-files provider
- You can launch
select-filesbycmd-backspaceor clickingfolder-iconon control-bar.
- search
editorbynarrow:search, you see lots ofeditormached items - But you want exclude items in markdown file?
- launch
select-files, all file paths are listed as item. - Then type
mdon query, you see markdown filepath that macheedmd. - Then add
!, now your query ismd!, this is treated as all files not matchingmd. enterto 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
specfolder, you can addspec/!as query. - e.g. To include
.jsfile only, you can set query to.js.
Want to skip to next-file, previous-file
- Use
n,pinread-onlymode.
I want narrow:symbols always shows up at right-most pane and don't want to close.
- Open
narrow:symbols( or maybe you want to usenarrow:fold) - Move this
narrow-editorby drag and drop to the place where you want. - From command-palette, execute
Narrow Ui: Protect. Nownarrow-editorprotected. - Protected
narrow-editoris not closed byctrl-g(narrow:close), and not closed by confirm byenter. - To close, use normal
cmd-wor close button on tab.