https://github.com/pdmlab/vim-cheatsheet
Yet another vim cheatsheet, created from personal use.
https://github.com/pdmlab/vim-cheatsheet
Last synced: 5 months ago
JSON representation
Yet another vim cheatsheet, created from personal use.
- Host: GitHub
- URL: https://github.com/pdmlab/vim-cheatsheet
- Owner: PDMLab
- License: bsd-3-clause
- Created: 2016-02-10T17:23:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-29T21:11:53.000Z (almost 8 years ago)
- Last Synced: 2025-06-01T11:42:20.228Z (about 1 year ago)
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vim cheat sheet for Ubuntu
## General
First, install ```vim-gtk``` to make sure copy / paste between vim and and system clipboard works:
```
sudo apt-get install vim-gtk
```
## Keyboard shortcuts
### Files
```:w ``` write file using a new name (save as)
```:w``` save current file
```:vnew``` create new file in vertically split window
```:new``` create new file in horizontally split window
```:tabedit ``` open in new tab
```:q``` close file / vim
```:q!``` close file / vim and discard changes
```:x``` close file / vim and save changes
### Navigation
```gg``` go to beginning of the file
```G``` go to the end of the file
```gt``` switch tabs by number (n = number of tab)
```CTRL+w``` switch between splits
```/``` find text
```n``` after ```/``` find next search result
```N``` after ```/``` find previous search result
### Selecting, copy/paste, formatting etc.
```V``` Visual Mode, now you can select parts of the file using arrow keys
```ggVG``` select all
```y``` copy selection to buffer
```p``` paste buffer
```dd``` delete current line
```u``` undo
```"+p``` paste from system clipboard
```"+y``` copy to system clipboard
```gg=G``` reformat file
```V=``` reformat selection
```=``` reindent current section
## Modes
Vim has several modes.
```Normal``` mode is active after you opened vim (or a file using vim).
In normal mode you can not edit text, but you can execute commands as shown below.
```Insert``` mode allows you to edit text. You can activate insert mode by pressing ```i``` in normal mode.
You can exit insert mode by pressing ```ESC```
```Visual``` mode allows you to select text.
It can be activated by hitting ```V```.
You can exit visual mode by pressing ```ESC```
## Configuration in ~/.vim/.vimrc
```set nocp``` enabling features which are not Vi compatible but really nice.
```set number``` enable line numbers
```syntax on``` enbale syntax highlighting
```filetype plugin indent on``` language-dependent indenting
```set backspace=indent,eol,start``` enable backspace key
## Plugins
Plugins are installed using Pathogen, a plugin system for vim.
So we have to install Pathogen first:
```
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
```
In ```~/.vim/.vimrc``` add:
```
execute pathogen#infect()
```
### FuzzyFinder
[FuzzyFinder](http://www.vim.org/scripts/script.php?script_id=1984) is a File Explorer for vim.
#### Installing FuzzyFinder
```
cd ~/.vim/bundle
git clone git@github.com:vim-scripts/L9.git
git clone git@github.com:vim-scripts/FuzzyFinder.git
```
#### Using FuzzyFinder
```:FufFile``` opens file explorer of ```FuzzyFinder```i
```CTRL+Enter``` opens a file in a new split
```CTRL+L``` opens a file in a new tab
As a shortcut to open ```FuzzyFinder``` file explorer in current folder, add this to ```~/.vim/.vimrc```:
```
map ,f :FufFile **/
```
Files can now be browsed using ```,f```.