Skip to main content

Vim Cheat Sheet



This is a small collection of tips and tricks I have collected for the vim text editor. This is by no means complete or a tutorial on how to use vim. Just a set of commands I don’t want to forget, but don’t use often enough to burn into memory, yet.
See the resources section below for a more complete introduction and a set of in-depth tutorials.

Navigation

Marks

ma" --> mark spot label it a
'a     --> jump to spot marked by label a

Copy and Paste Registers

Vim has a clipboard history stored in registers, you can also use these registers to cut and paste items to.
  "ad     " cut something to register a
  "ap     " paste something from register a
  :reg    " list registers

Deleting Lines

  :g/regexp/d    " delete all lines that match regexp
  :v/regexp/d    " delete all lines that do NOT regexp

  :15,20d       " delete lines 10-20

Buffer Management

  :ls             " matching list buffers
  :b [num|name]   " switch to buffer
  :b#             " switch to last buffer
  :bdel #         " delete buffer

Record Macro

  qa              " start recording macro in buffer a
  
  q               " end recording

Playback Macro

   @a
   50@a  (50 times)

Map System Command to Key Stroke

Map ctrl-j d to run system command /tmp/x.py
  :imap d =system('/tmp/x.py')

Toggle Spellcheck

  :map  :setlocal spell! spelllang=en_us

Map F1 to Esc

I often find myself trying to hit escape and accidentally hit F1, which opens help. Since, I’ve never on purpose hit F1 for help, I map my F1 key to ESC.
  map  
  imap  

Courtesy: http://mkaz.com/solog/system/vim-cheat-sheet.html

Comments

  1. Getting numbers from Numeric keypad in VIM

    export $TERM=ansi

    ReplyDelete

Post a Comment

Please post your comment

Popular posts from this blog

Save Widows remote desktop credentials

First, START > All Programs > Accessories > Remote Desktop Connection Type in the computer name and clock OPTIONS Check off the box that says save credentials Now connect, and you will be prompted for your username/password. Enter them. Now you should be connected to the remote computer. Close out of the remote session. Method 1 Create a .bat file that has the following command: START mstsc.exe /v: & exit Run the .bat file and the remote desktop session should open and submit your saved credetials automatically. Method 2 Type mstsc -v it will login without asking credentials. Method 3 Save the session as a .rdp file (e.g: myRemoteMachine.rdp) and Double click the rdp file to open the remote desktop session without asking for credentials.

Start with flask

1. Install python 2. Python comes with pip. Else install pip 3. pip install Flask 4. Create a file flaskFirst.py from flask import Flask app = Flask(__name__) @app.route('/') def index():     return 'Index Page' 3. Go to the path where the flaskFirst.py is present 4. export FLASK_APP=flaskFirst.py 5. flask run