Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| public:computer:vim_cheat_sheet [2022/03/21 18:27] – [References] alex | public:computer:vim_cheat_sheet [2023/01/01 01:06] (current) – [Examples] alex | ||
|---|---|---|---|
| Line 439: | Line 439: | ||
| |: | |: | ||
| - | ==== _gvimrc ==== | + | ==== _vimrc ==== |
| + | * Install Vundle< | ||
| + | $ git clone https:// | ||
| + | or | ||
| + | > cd %USERPROFILE% | ||
| + | > git clone https:// | ||
| + | > gvim .vimrc | ||
| + | </ | ||
| + | |||
| + | * Plugin | ||
| + | <sxh shell title: | ||
| + | set nocompatible | ||
| + | filetype off " required | ||
| + | set shellslash | ||
| + | |||
| + | " | ||
| + | " Specify a directory for plugins | ||
| + | " - For Neovim: stdpath(' | ||
| + | " - Avoid using standard Vim directory names like ' | ||
| + | "call plug# | ||
| + | |||
| + | " Make sure you use single quotes | ||
| + | |||
| + | " Shorthand notation; fetches https:// | ||
| + | "Plug ' | ||
| + | |||
| + | " Any valid git URL is allowed | ||
| + | "Plug ' | ||
| + | |||
| + | " Multiple Plug commands can be written in a single line using | separators | ||
| + | "Plug ' | ||
| + | |||
| + | " On-demand loading | ||
| + | "Plug ' | ||
| + | "Plug ' | ||
| + | |||
| + | " Using a non-default branch | ||
| + | "Plug ' | ||
| + | |||
| + | " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) | ||
| + | "Plug ' | ||
| + | |||
| + | " Plugin options | ||
| + | "Plug ' | ||
| + | |||
| + | " Plugin outside ~/ | ||
| + | "Plug ' | ||
| + | |||
| + | " Unmanaged plugin (manually installed and updated) | ||
| + | "Plug ' | ||
| + | |||
| + | " Plugin airline | ||
| + | "Plug ' | ||
| + | "Plug ' | ||
| + | |||
| + | "Plug ' | ||
| + | "Plug ' | ||
| + | "Plug ' | ||
| + | |||
| + | " Initialize plugin system | ||
| + | "call plug# | ||
| + | " | ||
| + | " set the runtime path to include Vundle and initialize | ||
| + | set rtp+=~/ | ||
| + | call vundle# | ||
| + | " alternatively, | ||
| + | "call vundle# | ||
| + | |||
| + | " let Vundle manage Vundle, required | ||
| + | Plugin ' | ||
| + | |||
| + | " The following are examples of different formats supported. | ||
| + | " Keep Plugin commands between vundle# | ||
| + | " plugin on GitHub repo | ||
| + | Plugin ' | ||
| + | " plugin from http:// | ||
| + | " Plugin ' | ||
| + | " Git plugin not hosted on GitHub | ||
| + | Plugin ' | ||
| + | " git repos on your local machine (i.e. when working on your own plugin) | ||
| + | " | ||
| + | " The sparkup vim script is in a subdirectory of this repo called vim. | ||
| + | " Pass the path to set the runtimepath properly. | ||
| + | Plugin ' | ||
| + | " Install L9 and avoid a Naming conflict if you've already installed a | ||
| + | " different version somewhere else. | ||
| + | " Plugin ' | ||
| + | |||
| + | Plugin ' | ||
| + | Plugin ' | ||
| + | Plugin ' | ||
| + | Plugin ' | ||
| + | Plugin ' | ||
| + | |||
| + | |||
| + | " All of your Plugins must be added before the following line | ||
| + | call vundle# | ||
| + | filetype plugin indent on " required | ||
| + | " To ignore plugin indent changes, instead use: | ||
| + | " | ||
| + | " | ||
| + | " Brief help | ||
| + | " : | ||
| + | " : | ||
| + | " : | ||
| + | " : | ||
| + | " | ||
| + | " see :h vundle for more details or wiki for FAQ | ||
| + | " Put your non-Plugin stuff after this line | ||
| + | " | ||
| + | " An example for a gvimrc file. | ||
| + | " The commands in this are executed when the GUI is started, after the vimrc | ||
| + | " has been executed. | ||
| + | " | ||
| + | " Maintainer: | ||
| + | " Last change: | ||
| + | " | ||
| + | " To use it, copy it to | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | |||
| + | " Make external commands work through a pipe instead of a pseudo-tty | ||
| + | "set noguipty | ||
| + | |||
| + | " set the X11 font to use | ||
| + | " set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1 | ||
| + | |||
| + | set ch=2 " | ||
| + | |||
| + | set mousehide " | ||
| + | |||
| + | " Make shift-insert work like in Xterm | ||
| + | map < | ||
| + | map! < | ||
| + | |||
| + | " Only do this for Vim version 5.0 and later. | ||
| + | if version >= 500 | ||
| + | |||
| + | " Switch on syntax highlighting if it wasn't on yet. | ||
| + | if !exists(" | ||
| + | syntax on | ||
| + | endif | ||
| + | |||
| + | " For Win32 version, have " | ||
| + | "if has(" | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | |||
| + | " Set nice colors | ||
| + | " background for normal text is light grey | ||
| + | " Text below the last line is darker grey | ||
| + | " Cursor is green, Cyan when ": | ||
| + | " Constants are not underlined but have a slightly lighter background | ||
| + | highlight Normal guibg=grey90 | ||
| + | highlight Cursor guibg=Green guifg=NONE | ||
| + | highlight lCursor guibg=Cyan guifg=NONE | ||
| + | highlight NonText guibg=grey80 | ||
| + | highlight Constant gui=NONE guibg=grey95 | ||
| + | highlight Special gui=NONE guibg=grey95 | ||
| + | |||
| + | endif | ||
| + | |||
| + | |||
| + | set guifont=D2Coding: | ||
| + | " set guifont=Source_Code_Pro: | ||
| + | |||
| + | if has(" | ||
| + | set encoding=utf-8 | ||
| + | |||
| + | source $VIMRUNTIME/ | ||
| + | behave mswin | ||
| + | |||
| + | if has(' | ||
| + | set keymodel=startsel | ||
| + | |||
| + | " set guifont=Source\ Code\ Pro: | ||
| + | " set guifont=JetBrains\ Mono\ Regular: | ||
| + | " set guifont=D2Coding\ ligature: | ||
| + | set renderoptions=type: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | " restore Ctrl-F to Page down | ||
| + | unmap < | ||
| + | elseif has(' | ||
| + | set guifont=JetBrains\ Mono\ 16 | ||
| + | set antialias | ||
| + | else | ||
| + | set guifont=JetBrains\ Mono\ 16 | ||
| + | endif | ||
| + | |||
| + | " Turn off toolbar | ||
| + | "set guioptions-=T | ||
| + | " Turn on menu | ||
| + | "set guioptions+=m | ||
| + | end | ||
| + | |||
| + | set smartindent | ||
| + | set tabstop=2 | ||
| + | set expandtab | ||
| + | set shiftwidth=2 | ||
| + | |||
| + | " colorscheme darkblue | ||
| + | |||
| + | "set statusline+=%# | ||
| + | "set statusline+=%{SyntasticStatuslineFlag()} | ||
| + | "set statusline+=%* | ||
| + | |||
| + | "let g: | ||
| + | "let g: | ||
| + | "let g: | ||
| + | "let g: | ||
| + | |||
| + | let g: | ||
| + | let g: | ||
| + | |||
| + | syntax enable | ||
| + | set background=dark | ||
| + | colorscheme solarized | ||
| + | |||
| + | set encoding=utf-8 | ||
| + | "set rop=type: | ||
| + | |||
| + | "let g: | ||
| + | |||
| + | set nu | ||
| + | set clipboard=unnamed | ||
| + | set laststatus=2 | ||
| + | set lines=50 | ||
| + | </ | ||
| + | |||
| + | * Plug | ||
| <sxh> | <sxh> | ||
| set nocompatible | set nocompatible | ||
| Line 671: | Line 910: | ||
| </ | </ | ||
| + | * Apply <sxh> | ||
| + | :source % | ||
| + | : | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Examples ===== | ||
| + | * '': | ||
| + | * '': | ||
| + | * '': | ||
| + | / | ||
| + | ^(?: | ||
| + | ^(?: | ||
| + | * '': | ||
| + | |||
| + | * '': | ||
| ===== References ===== | ===== References ===== | ||
| + | *{{youtube> | ||
| + | * command mode / edit mode | ||
| + | * i | ||
| + | * :q, :q!, :w, :w!, :wq, wq! | ||
| + | * <esc> i, a, I, A | ||
| + | * h, j, k, l, 0, $, w, b, 3w, 8w, | ||
| + | * H 화면위, M 화면 중간, L 화면끝, gg, G, 20G, ^u, ^d, {, } | ||
| + | * x, dd yy, p, *p | ||
| + | * command + object; d3w, dit, d, y, c, 3w, 3b, aw, at, ap, as, it, i", ip | ||
| + | * ., u, ^R | ||
| + | * **daw** delete a word, di{, di(, da(, di', da', ci[, df(, dt(, d/(sh, d/use | ||
| + | * /, +n, +N | ||
| + | * v, vaw, ^V | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| Line 684: | Line 953: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||