*`<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` or `npm 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](https://pqrs.org/osx/karabiner/index.html).
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.
```bash
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](http://mxcl.github.com/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](https://github.com/clvv/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](http://github.com/sorin-ionescu/prezto)
- [How to add your own ZSH theme](doc/zsh/themes.md)
### 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` or `gl`- More effective git log
-`git b` or `gb`- A list of branches containing the summary of the previous commit
-`git r` - Information about the source list
-`git t` or `gt`- Information about the tag list
-`git nb` or `gnb`- Just like checkoub -b, create a new branch
-`git cp` or `gcp`- cherry-pick -x (Show those branches which have been cherrypicked)
-`git simple` - A more concise command to build changelogs
-`git recent-branches` - Show you about the branches you have used recently
-`git unstage` / `guns` (remove from index) and `git 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 branch
-`Gdiff` 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.
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](doc/vim/navigation.md)
- [text object - Manipulate Ruby blocks, and more](doc/vim/textobjects.md)
- [modify the code - support of rails, commit, code block, highlight](doc/vim/coding.md)
- [tools - Indentation, paste buffer management, and more](doc/vim/utils.md)
- [usually do not add new command line improvements](doc/vim/enhancements.md)
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.
- 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 like `ysw#`.
- 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.
- Use `Cmd-1` to `Cmd-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 to `vim-tmux-navigator`。
-`Q` - Only force kill the window.Close window by `wincmd c`, if the same buffer has multiple corresponding windows, or kill the buffer when this is the last corresponding window`bwipeout`。
-`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)
-`Ctrl-p` Use `p` to paste and `Ctrl-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 type `ctrl-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)
-`,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 using `spring rspec`, one can make your Rails specs faster, by caching `Rails 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)
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.
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]`.
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:
Pry provides a better IRB that uses colors, tab completion, and other more tricks out of the box. You can also install [pry-nav](https://github.com/nixme/pry-nav) as a real debugger.
* 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 the `nvim-typescript` plugin to install