My small vim and tmux flow cheatsheet
I know that there are way too many vim and tmux cheatsheets out there. I want to share mine with a little timeline touch. It tries to capture frequent keys during my whole dev session. Any recommendation is welcome.
PS: I assume you have NERDTree plugin installed in vim.
Transcript:
- ctrl+alt+t => Open terminal
- tmux new => Create tmux session
- ctrl + b “ => Split pane horizontally
- ctrl + b % => Split pane vertically
- ctrl + b d => Detach
- ctrl + b $ => Rename session
- ctrl + b ctrl + right arrow => resize split
- ctrl + b [ => Scroll up in tmux pane output
- q => Quit from scrolling mode
- tmux a -t named_session => Continue tmux session
- vim .
- t => open in new tab
- gt => cycle tabs
- $ => End of line
- r => replace in place
- hjkl
- gt => Cycle tabs
- ctrl + w w => Switch splits
- gg => scroll top
- shift + g => scroll end
- 0 => Begining of the line
- u => undo
- ctrl r => Redo
- ctrl % => Matching paren
- gd => Go to local definition
- g* => Go to the matching word
- a => Insert from the next letter
- \s => Save workspace
- gt => cycle tabs
- s => Open in new split
- ctrl+w w=>Switch splits
- m => NerdTree system menu
- a => a childnode
- t => open in new tab
- ctrl + b n => Cycle windows
- vim .
- tmux new => Create tmux session
Here is my pretty messy experimental .vimrc:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
" plugin on GitHub repo | |
"Plugin 'tpope/vim-fugitive' | |
" plugin from http://vim-scripts.org/vim/scripts.html | |
" Plugin 'L9' | |
" Git plugin not hosted on GitHub | |
"Plugin 'git://git.wincent.com/command-t.git' | |
" git repos on your local machine (i.e. when working on your own plugin) | |
"Plugin 'file:///home/gmarik/path/to/plugin' | |
" The sparkup vim script is in a subdirectory of this repo called vim. | |
" Pass the path to set the runtimepath properly. | |
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} | |
" Install L9 and avoid a Naming conflict if you've already installed a | |
" different version somewhere else. | |
" Plugin 'ascenator/L9', {'name': 'newL9'} | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'scrooloose/nerdtree' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'kien/ctrlp.vim' | |
Plugin 'bling/vim-airline' | |
Plugin 'scrooloose/nerdcommenter' | |
Plugin 'jistr/vim-nerdtree-tabs' | |
"Plugin 'Valloric/YouCompleteMe' | |
Plugin 'ajh17/VimCompletesMe' | |
Plugin 'tpope/vim-surround' | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'ervandew/supertab' | |
Plugin 'flazz/vim-colorschemes' | |
Plugin 'tpope/vim-markdown' | |
Plugin 'farmergreg/vim-lastplace' | |
Plugin 'elzr/vim-json' | |
Plugin 'tpope/vim-sensible' | |
Plugin 'thaerkh/vim-workspace' | |
Plugin 'klen/python-mode' | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" To ignore plugin indent changes, instead use: | |
"filetype plugin on | |
" | |
" Brief help | |
" :PluginList - lists configured plugins | |
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate | |
" :PluginSearch foo - searches for foo; append `!` to refresh local cache | |
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" Put your non-Plugin stuff after this line | |
set paste | |
" The default vimrc file. | |
" | |
" Maintainer: Bram Moolenaar <[email protected]> | |
" Last change: 2017 Jun 13 | |
" | |
" This is loaded if no vimrc file was found. | |
" Except when Vim is run with "-u NONE" or "-C". | |
" Individual settings can be reverted with ":set option&". | |
" Other commands can be reverted as mentioned below. | |
" When started as "evim", evim.vim will already have done these settings. | |
if v:progname =~? "evim" | |
finish | |
endif | |
" Bail out if something that ran earlier, e.g. a system wide vimrc, does not | |
" want Vim to use these default values. | |
if exists('skip_defaults_vim') | |
finish | |
endif | |
" Use Vim settings, rather than Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
" Avoid side effects when it was already reset. | |
if &compatible | |
set nocompatible | |
endif | |
" When the +eval feature is missing, the set command above will be skipped. | |
" Use a trick to reset compatible only when the +eval feature is missing. | |
silent! while 0 | |
set nocompatible | |
silent! endwhile | |
" Allow backspacing over everything in insert mode. | |
set backspace=indent,eol,start | |
set history=200 " keep 200 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set wildmenu " display completion matches in a status line | |
set ttimeout " time out for key codes | |
set ttimeoutlen=100 " wait up to 100ms after Esc for special key | |
" Show @@@ in the last line if it is truncated. | |
"set display=truncate | |
" Show a few lines of context around the cursor. Note that this makes the | |
" text scroll if you mouse-click near the start or end of the window. | |
set scrolloff=5 | |
" Do incremental searching when it's possible to timeout. | |
if has('reltime') | |
set incsearch | |
endif | |
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it | |
" confusing. | |
set nrformats-=octal | |
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries. | |
if has('win32') | |
set guioptions-=t | |
endif | |
" Don't use Ex mode, use Q for formatting. | |
" Revert with ":unmap Q". | |
map Q gq | |
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, | |
" so that you can undo CTRL-U after inserting a line break. | |
" Revert with ":iunmap <C-U>". | |
inoremap <C-U> <C-G>u<C-U> | |
" In many terminal emulators the mouse works just fine. By enabling it you | |
" can position the cursor, Visually select and scroll with the mouse. | |
if has('mouse') | |
set mouse=a | |
endif | |
" Switch syntax highlighting on when the terminal has colors or when using the | |
" GUI (which always has colors). | |
if &t_Co > 2 || has("gui_running") | |
" Revert with ":syntax off". | |
syntax on | |
" I like highlighting strings inside C comments. | |
" Revert with ":unlet c_comment_strings". | |
let c_comment_strings=1 | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
" Enable file type detection. | |
" Use the default filetype settings, so that mail gets 'tw' set to 72, | |
" 'cindent' is on in C files, etc. | |
" Also load indent files, to automatically do language-dependent indenting. | |
" Revert with ":filetype off". | |
filetype plugin indent on | |
" Put these in an autocmd group, so that you can revert them with: | |
" ":augroup vimStartup | au! | augroup END" | |
augroup vimStartup | |
au! | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid, when inside an event handler | |
" (happens when dropping a file on gvim) and for a commit message (it's | |
" likely a different one than last time). | |
autocmd BufReadPost * | |
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' | |
\ | exe "normal! g`\"" | |
\ | endif | |
augroup END | |
endif " has("autocmd") | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. | |
" Only define it when not defined already. | |
" Revert with: ":delcommand DiffOrig". | |
if !exists(":DiffOrig") | |
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
endif | |
if has('langmap') && exists('+langremap') | |
" Prevent that the langmap option applies to characters that result from a | |
" mapping. If set (default), this may break plugins (but it's backward | |
" compatible). | |
set nolangremap | |
endif | |
" give a shortcut key to NERD Tree | |
map <F2> :NERDTreeToggle<CR> | |
" Auto open nerdtree by default in every | |
" tab. | |
autocmd VimEnter * NERDTree | |
"autocmd BufEnter * NERDTreeMirror | |
autocmd VimEnter * wincmd w | |
" haku trials. | |
"autocmd VimEnter * wincmd w | |
" Vim airline tabs. | |
let g:airline#extensions#tabline#enabled = 1 | |
filetype plugin indent on | |
"show existing tab with 4 spaces width | |
set tabstop=2 | |
" when indenting with '>', use 4 spaces width | |
" On pressing tab, insert 4 spaces | |
set expandtab | |
set tabstop=2 | |
" Still it is a \t. It is just that | |
" Vim will interpret it to be having | |
" a width of 4. | |
set softtabstop=2 " Sets the number of columns for a TAB | |
set expandtab " Expand TABs to spaces | |
set smarttab | |
" Highlight the words while you | |
" are navigating on them. | |
autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\')) | |
let NERDTreeShowHidden=2 | |
colorscheme Monokai | |
" setlocal foldmethod=syntax | |
" Automatic workspace management. | |
nnoremap <leader>s :ToggleWorkspace<CR> | |
" Enable autosave. | |
let g:workspace_autosave_always = 2 | |
" Enable mouse | |
set mouse=a | |
" Do not indent it while I'm pasting something from outside. | |
set pastetoggle=<F3> | |
" Keep directories clean. | |
"set backupdir=$TEMP// | |
"set directory=$TEMP// | |
set clipboard=unnamed | |
set paste | |
set ma | |
autocmd FileType vim let b:vcm_tab_complete = 'vim' | |
set tabstop=4 " The width of a TAB is set to 4. | |
" Still it is a \t. It is just that | |
" Vim will interpret it to be having | |
" a width of 4. | |
set shiftwidth=2 " Indents will have a width of 4 | |
set softtabstop=2 " Sets the number of columns for a TAB | |
set expandtab " Expand TABs to spaces | |