Useful vim tips and tricks

Delete until specified character

Use dtc, where c is any character, e.g. for you, you want dt" This will delete upto but not including c. If you had:

delete until exclamation point!

And the cursor was at the first space and you typed dt!, you would get:

delete!

Also dfc.

This will delete upto and including c.

Using df! on the same example above would give you:

delete

Just about any “motion” can be used for the d, c, y and similar commands.

source

Find and replace within specified line range

Example: replace all occurences of foo with bar between lines 3 and 10:

:3,10s/foo/bar/g

To perform find and replace in the whole document:

:%s/foo/bar/g

The dot . represents the current line and the dollar sign $ the last lign.

source

Select Current Paragraph (in visual mode)

vip

Very useful when developing with Imandra, to copy and paste the lemma you’re currently editing into the terminal running Imandra CLI.

Install Vundle package manager for NVim

Quick Guide For Vundle packages installation - In short:

Open terminal and edit the vimrc file (using vim ~/.vimrc)

paste the name of package according to the documentation, paste it between
vundle#begin() and vundle#end.

call vundle#begin()
Plugin 'PluginAuthor/PluginName'
call vundle#end()

for example:

call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'airblade/vim-gitgutter'
Plugin 'dracula/vim'
Plugin 'tpope/vim-fugitive'

call vundle#end()    

There might be additional installation steps (compilation, run a script, etc.) See the plugin’s home page for details.

open Terminal and open vim (just vim ) and Type :VundleInstall , On packages installation window, Wait until Vundle installer is getting finished.

source

Using Marks

mx tells Vim to add a mark called x.

`x tells Vim to return to the line and column for mark x.

'x tells Vim to return to the beginning of the line where mark x is set.

`. moves the cursor to the line and column where the last edit was made.

'. moves the cursor to the line where the last edit was made.

'" moves the cursor to the last position of the cursor when you exited the previous session.

:marks shows all marks set.

:marks x shows the mark named x.

:jumps shows the jumplist.

Ctrl-o moves the cursor to the last jump.

Ctrl-i moves the cursor to the previous jump.

H moves the cursor to the top of the screen or viewport.

M moves the cursor to the middle of the screen or viewport.

L moves the cursor to the bottom of the screen or viewport.

source

There are no notes linking to this note.

There are no papers linking to this note.


Here are all the notes in this garden, along with their links, visualized as a graph.

Adversarial perturbation to...Can we (and should we)...Certified compilers and proof...Constructive logicCurry Howard correspondenceDuelling banjos drama in the...Equivalence checkingExporting ocaml from imandraHalf marathon afterthoughtsHow to set up a plausible...How to make a sunrise alarm...How to make a sunrise alarm...How to make a sunrise alarm...Jupyter notebook launch...Lairg to john'o'groats bike...Marabou Imandra interfacingMarkov process modelMethodologyMonte carlo processNeural network verification ...Ocaml decoder libraryProof production for neural...Reading listType theory with agdaUbuntu housekeepingUseful imandra tipsUseful git commandsUseful vim tips and tricksUsefull miscellaneous snippetsVerifying an algorithm with...On the Dangers of Stochastic...Intuitionistic Type TheorySpinoza on ModalityAttention is All you NeedFormal Monotony Analysis...