Giter VIP home page Giter VIP logo

vim-config's Introduction

vim

My own configuration and cheatsheet for vim, feel free to copy and make suggestions.

Setup

  1. Copy the .vimrc into your home directory (i.e. ~/) or symlink with ln -s /path/to/vim-config/.vimrc ~/.vimrc,
  2. Install Vundle by running git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim,
  3. Run vim +PluginInstall +qall in shell, or ":PluginInstall" in vim, to install all of the plugins with Vundle,
  4. Symlink the language-dependent configurations (e.g. rb.vim or py.vim) to ~/.vim/ftplugin/LANGUAGE.vim,
  5. (Optional) Reload live vim sessions with the command :source ~/.vimrc.

Theme

I use this in conjunction with iTerm and Visual Studio Code's theme

YouCompleteME

In order for YouCompleteMe to work, follow the installation instructions on their Github page for your system. On MacOS, the plugin only works with MacVim, which can be installed with Brew - trying to open the plugin directly will freeze the terminal. To install MacVim, run brew install macvim, and alias vim with alias vim="mvim -v".

Gutentags

Gutentags is used to generate ctags. In order for the plugin to run, must install ctag on your machine (i.e. sudo apt install exuberant-ctags).

Vundle Installation

See their Gihub page for information.

YouCompleteMe

YouCompleteMe is a plugin for vim that has support for autocomplete. To enable it, run cd ~/.vim/bundle/YouCompleteMe && ./install.py --all to complete setup. See their Github page for more information on setup.

When the autcomplete shows up, use TAB key to cycle through suggestions or shift + TAB to cycle backwards.

CtrlP

CtrlP is a "Full path fuzzy file, buffer, mru, tag, ... finder for Vim".

Cheatsheet

To check what a key is current mapped, use nmap.

Search Keyword

  • grep -rnw './parent_path' -e 'keywords'

Open File

  • In current pane, use :e FILE_NAME

NERDTree

NERDTree is a tool for browsing files in a tree similar to those of IDEs.

  • ctrl + n - toggle NERDTree (a file tree browser), can be changed in the .vimrc file
  • I (shift + i) - to toggle showing hidden files

Copy, Cutting, & Pasting

  • To select, v to select characters, V to select whole lines, or use the mouse to highlight when mouse mode is enabled,
  • To copy, y for "yank",
  • To cut, d,
  • To paste before cursor press P. to paste after cursor press p.

Alternatively, in visual mode CTRL-c copies and CTRL-x cuts.

MacVim on MacOS and vim-gtk (should uninstall vim and install vim-gtk) should allow yank and cut to copy to system clipboard.

Folding

  • zc closes a fold
  • zo opens a fold

Saving

  • :w writes the current changes to disk,
  • <CTRL> z is a shortcut that writes changes to disk and changes back to normal mode.

Undo & Redo

In normal mode:

  • :u or simply press u will undo a previous change
  • ctrl + r will redo the previously undone change

Tabs

  • :tabnew FILE_NAME - open FILE_NAME in new tab
  • :tabmove N - move tab to Nth position, if argument is not provided, moves tab to the last position

Panes

  • vs filename - open in new vertical split
  • sp filename - open in new horizontal split

Resizing:

  • resize +5 to increase the height of the pane
  • vertical resize +5 to increase the width of the pane

Alternatively, ctrl-w + and ctrl-w - to resize the height of the current window, ctrl+w > and ctrl+w < to resize the width of the current window. To resize all windows, ctrl-w =.

Commenting/Uncommenting

  • \ c <SPACE> toggles commenting/uncomment of lines.

Searching

  • Enter the command :/ (forward) or :? (backward), type in the search query, then hit to search. Hit to search for the next forward instance, and to search for the next backward instance
  • :noh clears the highlighted search terms
  • (Not specific to VIM, but helpful) Examples searching for files ending in ".erb" for the term "card-panel" - grep -R --include "*.erb" "card-panel" .

References

These resources below are used as references to customize this .vimrc.

  1. https://dougblack.io/words/a-good-vimrc.html
  2. https://www.jacoballred.com/web-dev/enabling-mouse-support-in-vim/

vim-config's People

Contributors

treble-maker123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.