21 KiB
Ruilisi dotfiles
Requirements
zsh
, tmux
, vim
, ag
are installed and zsh is set as your login shell:
chsh -s $(which zsh)
Install
bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotfiles/master/install.sh`"
Shortcuts
Tmux
Prefix is defined as C-A
(PRE
for short)
Scroll Mode
PRE [
: Enter Scroll Mode
Shortcut | Function |
---|---|
S-V |
Select Text |
Enter |
Copy Text |
] |
Paste text copied from scroll mode |
Vim
<L>
: Short for<localleader>
, which is\
in our setup
Defined by Us
Shortcut | Function |
---|---|
C-v |
Enter visual mode |
C-x C-v |
Paste text from system clipboard |
\<L\>tp |
toggle paste |
Defined by Vim
Shortcut | Function |
---|---|
o |
insert a new line below |
S-o |
insert a new line above |
0 |
go to the beginning of the line |
$ |
go to the end of the line |
v |
enter character selection mode |
x |
delete selected content |
V |
enter line selection mode |
y |
copy selected content |
p |
paste copied content |
Ctrl+u |
page up |
Ctrl+d |
page down |
:w |
save file |
:q |
quit vim |
:/ keyword |
search |
n |
go to the next content |
S-N |
go to the previous content |
w |
move forward one word |
b |
move back one word |
gg |
move to the top of the file |
S-G |
move to the bottom of the file |
Ctrl+\ |
show(hide) the Buffers |
[spc] c l |
(un)comment the selected line |
%s key1/key2/g |
replace Key1 with Key2 |
vim && markdown
- Install
prettier
:yarn global add prettier
ornpm install --global prettier
- Open vim and enter command:
:SPUPdate
Q&A
How to edit command line in vim
During editing command line, press esc
to enter normal mode, then press C-x C-e
to edit current command line in vim.
install iTerm Solarized Colors
YADR will install the Solarized color scheme into iTerm. You can choose Solarized Dark in Profiles => Colors => Load Presets.
swap the positions of caps-lock and escape by Karabiner-Elements.
Escape is the most commonly used key in vim. The old keyboard used to have the Escape as big as tab
, the worst part of the Apple keyboard is that the ESC
key is too small. However,we can swap the roles of ESC
key and Caps
key to solve these problems. If you keep tapping on the small target in the corners, you woll definitely reduce your efficiency drastically, and maybe you will cause small inijuries to your hands to repeated muscle force.
Set a system-level hotkey for iTerm (Keys=>Hotkey)
We recommend using Cmd-Escape
, which is actually Cmd-Capslock
(because the roles are interchanged).
Select "Use Lion-style full screen" in the General of iTerm.
After this setting, you will get a large screen that can be switched without having to go through the switching space.
Cancel Prefer native fullscreen in the Advanced Settings of MacVim.
Lion-style space switching will reduce all efficiency for no reason, just like iTerm.
If you want to run on the terminal
- Make sure that your terminal has installed the Solarized color scheme!
- If you don't want to use a terminal with solarized color matching, then makr sure you did this:
let g:yadr_using_unsolarized_terminal = 1
in ~/.vimrc.before
- if you want to use an alternavtive color scheme, such as Gruvbox, then do this in your
~/.vimrc.after
:
let g:yadr_disable_solarized_enhancements = 1
colorscheme base16-twilight
Upgrade
Upgrade is very simple.
cd ~/.yadr
git pull --rebase
rake update
What has been included and how do I configure it?
Keep reading to learn more about what YADR has to offer you!
Homebrew
Homebrew is a missing OSX package management system, and it will be installed automatically.
We automatically installed some commonly used packages, such as ctags, git, macvim, hub, and RipGrep (‘rg’). Note that our auto-completion plugin requires MacVim to support Lua. The installer knows how to install it, but if you have installed it before, you need to manually delete your previous MacVim.
ZSH
Think of Zsh as a more awesome Bash, but without much learning costs. It will do automatic spelling correction, grammar highlighting, and more for the command line you write. We have also added many enhancements:
- Vim mode and bash style historical anti-query:
Ctrl-R
- Insert the result of the previous command:
Ctrl-x,Ctrl-l
- Fuzzy match-if you type the wrong folder name, tab completion will correct it.
- fasd ubtegration - Entering
z
will help you semi-automatically match the recently used folders. Tab completion is also tuen on. - Prezto - the zsh behind YADR's
- How to add your own ZSH theme
Alias
Most of the things we use every day can be done with two to three character aliases. Please modify them yourself:
ae # alias edit
ar # alias reload
Git customization:
YADR will take over your ~/.gitconfig, so if you want to store your git username and other settings, please put them in ~/.gitconfig.user
We recommend setting your user information in this file. In addition, you can set your environment variables appropriately in your ~/.secrets.
git l
orgl
- More effective git loggit b
orgb
- A list of branches containing the summary of the previous commitgit r
- Information about the source listgit t
orgt
- Information about the tag listgit nb
orgnb
- Just like checkoub -b, create a new branchgit cp
orgcp
- cherry-pick -x (Show those branches which have been cherrypicked)git simple
- A more concise command to build changelogsgit recent-branches
- Show you about the branches you have used recentlygit unstage
/guns
(remove from index) andgit uncommit
/gunc
(Revoke to the moment before the last commit-if the code has been pushed, this operation will be very dangerous) Alias- Some reasonable default settings, such as optimizing merged branch information, pushing only the current branch, deleting status prompts, and using easy-to-remember prefixes in the diff process: (i)ndex, (w)ork tree, (c)ommit and (o)bject
- Slightly optimized the color of diff
gdmb
(g)it (d)elete (m)erged (b)ranches - Delete all branches that have been merged into the current branchGdiff
Display changes
vim-gitgutter
]h
next hunk(change point)[h
previous hunk<Leader>ha
Put the hunk into the state area to save<Leader>hr
Revoke the hunk
RubyGems
.gemrc is included. No need to enter gem install whatever --no-ri --no-rdoc
. --no-ri --no-rdoc
anymore, because it's all done by default.
Settings of Tmux
tmux.conf
provides some reasonable default settings for tmux on Mac OS, such as a powerful status bar and VIM keyboard bindings. You can modify the configuration in ~/.tmux.conf.user
.
Make everything Vim stylized
The provided inputrc and editrc will transform many of your command-line tools-such as mysql and irb-into vim style. And editrc also contains a Ctrl-R reverse history search function, which is very useful in irb, postgres command line, etc.
Github problems: ghi gem
We included the ghi
command. Try ghi list
, and have fun in managing issues using the command line!
Vim - Which ones are included?
- navigation - NERDTree, EasyMotion, CtrlP and more
- text object - Manipulate Ruby blocks, and more
- modify the code - support of rails, commit, code block, highlight
- tools - Indentation, paste buffer management, and more
- usually do not add new command line improvements
Some of the most useful commands provided by YADR are listed below. This is not a comprehensive list. If you want to dig out more information, contact a few of them every day, and then start to look at the plugins provided in the above list to learn more.
Tmux
h
(jkl): ←(↓↑→)move panec-a c
: Create a new panec-a s
: Split panes up and downc-a v
: Split panes left and rightc-a x
: Kill panec-a H
(JKL): ←(↓↑→)Move dividing linec-a ,
: Switch to Tmux command line modec-a d
: Exit Sessionc-a D
: Choose to exit Sessionc-a 1
(23456789): Enter pane 1(23456789)
导航
,z
- 到前一个缓冲区 (:bp),x
- 到下一个缓冲区 (:bn)Cmd-j
及Cmd-k
用函数来上下粗略的移动(Linux中的Alt
)Ctrl-o
- 之前的光标位置 - 这是一个标准的健映射,但很有用,所以这边给出来了Ctrl-i
- 对应于Ctrl-O(再一次, 这是标准的)
搜索/代码导航
,f
- 快速查找class的定义(exuberant ctags必须被安装过),F
- 类似于,f
,但是会用垂直分割的界面显示,gf
或Ctrl-f
- 和vim中正常的gf一样 (进入文件), 但是在一个垂直分割的界面中 (碰到带有行数的,例如file.rb:123,一样能行)gF
- 标准的vim键映射, 为了完整性而列在这里 (带有行数也行),k
- 搜索当前光标下的单词,然后将结果显示到quickfix窗口里,K
- Grep当前单词一直到下一个感叹号(在ruby foo!方法中很有用)Cmd-*
- 将所有当前单词出现的地方高亮(与正常的*
一样,除了不移动),hl
- 切换搜索高亮,gg
或,ag
- 在命令行中grep,在双引号之间输入。 使用RipGrep。- 在使用
,gg
搜索过,你可以用Ctrl-x
和Ctrl-z
来浏览 (或者标准vim命令:cn
和:cp
) ,gd
- 当光标在函数名字上的时候,Grep定义 (检索'def [function name]'),gcf
- 在当前文件搜索对当前文件的索引//
- 清除搜索,,w
(别名,<esc>
) 或者,,b
(别名,<shift-esc>
) - EasyMotion, 一个让你有种vim统治者的工具,它能将所有屏幕上所有可以跳入的地方全部高亮。,mc
- 将该单词标记为多光标处理模式(就像sublime). 用Ctrl-n
(下一个),Ctrl-p
(前一个),Ctrl-x
(跳过) 来添加更多的光标, 然后就像正常用vim那样,例如修改单词。gK
- 打开cursor底下这个单词的文档。- Spacebar - Sneak - 在一行中通过输入两个字符来移动。就像是vim的
f
但更加精确。 :Gsearch foo
- 全局搜索, 然后使用正常的%s/search/replace/g
紧接着用:Greplace
来在所有的文件中作替换操作。结束后,使用:wall
来写入所有文件。
文件导航
,t
- CtrlP 模糊文件选择,b
- CtrlP 缓冲区选择 - 非常适用于想跳入一个你已经打开的文件Cmd-Shift-M
- 跳入方法- CtrlP 在当前缓冲区里作标签化搜索,jm
跳入模型内。其他,j
键映射:,jc
控制器,,jh
帮助集, 等等。Cmd-Shift-N
- NERDTree toggle (Linux中的Alt
)Ctrl-\
- 在NERDTree中显示当前文件Cmd-Shift-P
- 清除CtrlP缓存
A better way to press keys for common editing commands
- Autocomplete: Ctrl-[SPC]. snipmate code block: Tab。
- Wrap a word with these symbols:
,#
,"
,'
,]
,)
,}
。# Is for #{ruby string insertion}. It can also run in Visual mode (thanks @cj). Normally, they do it through something likeysw#
. - Change the content of the tag:
Cmd-'
,Cmd-"
,Cmd-]
,Cmd-)
... You don’t need to be in the tag。(Alt
in Linux) - Go to the previous editing position
,.
(just like'.
) Because'
is very difficult for the little finger. ,ci
To change anything with a pair of quotes/parentheses, etc.
Option window, window, split bar
- Use
Cmd-1
toCmd-9
to switch to any specific option window(like iTerm and Chrome) - the option window must be set to the display number(Alt
in Linux) Ctrl-h,l,j,k
- use to move to left、right、top、bottom commpartment. This is still valid when vim and the split bar are together, thanks tovim-tmux-navigator
。Q
- Only force kill the window.Close window bywincmd c
, if the same buffer has multiple corresponding windows, or kill the buffer when this is the last corresponding windowbwipeout
。vv
- Vertical separation (Ctrl-w,v
)ss
- Horizontal separation (Ctrl-w,s
),qo
- Open quickfix window (The output of grep will go to this window),qc
- close quickfix
Tools
Ctrl-p
Usep
to paste andCtrl-p
to cycle through the previous pasteable content. Provided by YankRing.,yr
- View yankring-the list of content you copied earlier. Of course, you can typectrl-p
after pasting to cycle through the previously copied content.crs
,crc
,cru
use abolish.vim to force the use of snake_case, camelCase, and UPPERCASE.:help abolish
can view more content.:NR
- NarrowRgn - Use this command on the selected text to create a segmented display area generated from the text. Try it, and then use:wq
to return.,ig
- Toggle indentation visualization style,cf
- Copy the file name (full path) of the current file to the paste buffer of the system (not vi),cn
- 同上,但仅为文件名,yw
- 从一个单词内部的任何一个地方拉取这个单词(所以你不需要到单词的起始位置),ow
- 用当前拉取区域的内容(即复制的内容)覆盖当前光标所在单词 - 你可以在当前单词的任何地方。为你省去可视选择的过程。,ocf
- 打开所有改过的文件(从@garybernhardt偷过来的)。将所有git中改过的文件全部分割显示出来。,w
- 删除尾部空白字符sj
- 将一行例如一个一行散列{:foo => {:bar => :baz}}分割为多行的散列(j = 向下)sk
- 撤销裂开的链接(k = 向上),he
- Html 字符转义,hu
- Html 字符反转,hp
- Html 预览 (用Safari打开)Cmd-Shift-A
- 对其 (输入一个字符/表达式来对其, 在可视化模式或者它本身情况下都能工作) (Linux里的Alt
):ColorToggle
- 打开#abc123颜色高亮(css中有效):Gitv
- Git记录的浏览器,hi
- 显示当前的高亮组。如果你不喜欢什么东西的颜色, 先用这个, 然后在你的vimrc.after中hi! link [groupname] [anothergroupname]
来重新映射颜色。你可以通过使用:hi
来查看所有可用的颜色。,gt
- Go Tidy - 清理你的html代码 (在可视选择情况下可用):Wrap
- 包裹长行(例如在编辑markdown时)Cmd-/
- 切换注释 (通常情况下gcc中从tComment来) (Linux中是Alt
)gcp
(注释一段)
Rails & Ruby
,vv
&,cc
to switch between view and controller-they are the mappings corresponding to :Rcontroller and :Rview. Explore: R family commands can learn more about the fun of rails.vim!,rs
&,rl
to run rspec or a spec line in iTerm (check the iTerm window for information).,ss
&,sl
To achieve the same thing, by usingspring rspec
, one can make your Rails specs faster, by cachingRails env
(must have spring gem installed).- vim-ruby-refactoring - Try
,rem
,,rel
to extract method or let statement Ctrl-s
- open the relevant spec to the split window. Similar to :A and :AV in rails.vim, but it is faster to notice the fast_spec directory and input.:Bopen [gem name]
navigate into the gem (@tpope/vim-bundler).,gcp
- Grep the current Partial to find all references to the current view partial.,orb
- Go to the ruby block one level. Take you from the nested block to the previous level (very useful for rspec)
Vim Dev
,vc
- (Vim command) Copy the command under the cursor and run it. Very useful for testing single-line changes in vimrc.,vr
- (Vim re-documented) Use the current file as a vim file to load the source.
SpaceVim Interface elements:
The interface elements of SpaceVim start with [SPC] t or [SPC] T. You can view the second-level instructions by pressing the [SPC] key in the vim window. In the same way, press the required second-level instructions and then you can check the three Level instructions to view.
SPC t h s
- Show/hide syntax highlightingSPC t n
- Show/hide line numberSPC t h h
- Highlight current lineSPC T m
- Show/hide the menu bar (no difference is seen)SPC T t
- Show/hide the toolbar (don’t see the difference)SPC [1-9]
- Jump to the specified window
Switch Tab:
When multiple files are opened, the files will be listed in the tab bar in the form of Tabs, and you can switch to the Tab with the corresponding serial number via \[1-9]
.
\1
- Open tag 1\2
- Open tag 2\3
- Open tag 3\4
- Open tag 4\5
- Open tag 5\6
- Open tag 6\7
- Open tag 7\8
- Open tag 8\9
- Open tag 9
File tree:
The file tree is used to display the file directory where the currently opened file is located. SPC f t/<F3>
-Open the file tree
Shortcut keys in the file tree:
i
- Split a new window vertically and jumpgi
- Split a new window vertically without jumpings
- Split a new window horizontally and jumpgs
- Split a new window horizontally without jumpingt
- Open a new window in a new tab and jumpT
- Open a new window in a new tab without jumpingo
- Open the currently selected file or directory and jumpgo
- Open the currently selected file or directory without jumping
vim cursor operation:
k
- Move cursor upj
- Move cursor downh
- Move cursor leftl
- Move cursor rightgg
- Move to top of the fileG
- Move to bottom of the file[Ctrl] g
- Show current cursor position[Num] G
- Cursor to the specified line0
- Cursor to the beginning of the line[Num] w
- Move the cursor to the beginning of the specified number of words[Num] e
- Move the cursor to the end of the specified number of words
vim mode switch:
[Esc]
- Exit current mode
i
- Insert mode
v
- Select mode
R
- Replace mode
Document operation:
q
- quitw
- savewq
- save & quitq!
- foce quit
Document editing:
-
y
- Copy selected area -
yy
- Copy entire line -
p
- Paste -
o
- Insert a row below -
O
- Insert a row above -
A
- End of line insertion -
a
- Insert to the right of the cursor -
i
- Insert to the left of the cursor -
u
- Undo operation -
U
- Undo operation by line -
[Ctrl] R
- Redo -
x
- Delete selected area -
dw
- Delete word -
d$
- Delete to end of line -
dd
- Delete entire line -
d[num]w
- Delete the specified number of words -
r
- Replace a character -
:s/A/B
- Replace the first A in the line with B -
:s/A/B/g
- Replace all A in this line with B -
:[num1,num2]s/A/B/g
- Replace A in the specified line with B -
:%s/A/B/g
- Replace all A in the current tab with B
Document query:
:/A
- Find A in the document:/A
- Find A in the document, ignoring casen
- To the nextN
- To the previous:nohlsearch
- Cancel highlight:set hls is
- Highlight query results:set ic
- Ignore case
Extend or reload YADR settings
- Debug vim mapping
- Reload vim settings through ~/.vimrc.after or similar files
- Add your own vim plugin
Miscellaneous
OSX Hacks
The osx file is a bash script with reasonable default settings for developers or high-power users. Read it before running it. use:
bin/osx
These special skills are centered on Lion. Not necessarily on other OSs. My favorite modules include:
- Extremely fast repeated keystroke speed (now you can achieve fast scrolling through j/k)
- No disk mirror verification (downloaded files open faster)
- Display the contents of the ~/Library folder in the finder (hidden in Lion)
Macvim has trouble with Lua?
brew uninstall macvim
brew remove macvim
brew cleanup
brew install macvim --custom-icons --with-override-system-vim --with-lua --with-luajit
Terminal Vim has trouble with Lua?
Installing a terminal Vim (together with lua) through Ruby managed by RVM will cause a segfault on the neocomplete plugin. Try to uninstall vim, and then use system ruby to uninstall vim:
brew uninstall vim
rvm system do brew install vim --with-lua
Pry
Pry provides a better IRB that uses colors, tab completion, and other more tricks out of the box. You can also install pry-nav as a real debugger.
Learn more about YADR's pry customization and how to install
Language support
Typescript
fix SpaceVim Unknown function: TSOnBufEnter
- References
- Resolution steps
- Delete cache rm -rf ~/.cache/vimfiles/.cache
- Open vim run
:CheckHealth
check the current vim status, and fix any errors. - Reopen vim and run
:UpdateRemotePlugins
- If it still doesn't work, add
call dein#reinstall(['nvim-typescript'])
to~/.local/share/nvim/rplugin.vim
, reopen vim and wait for thenvim-typescript
plugin to install