Skip to content

Instantly share code, notes, and snippets.

@BastianHofmann
BastianHofmann / mad_vim_skills_20.md
Created January 29, 2019 09:56
Mad VIM Skills #20

Use :sort to sort selected lines alphabetically. (:sort u to remove duplicates; :sort! to sort desc, :sort n for numeric sorting)

package main
import (
"bytes"
"fmt"
"bufio"
"log"
"os"
)
package main
import "fmt"
func main() {
m := make(map[rune]int)
var twos, threes int
input := []string{"aabbffuuu", "zzaaafff", "ff"}
@BastianHofmann
BastianHofmann / mad_vim_skills_19.md
Created October 31, 2018 08:54
Mad VIM Skills #19

Use :[from],[to]s/[search]/[replace]/g to replace all occurrences of [search] with [replace] on the lines from [from] to [to].

@BastianHofmann
BastianHofmann / mad_vim_skills_18.md
Created October 27, 2018 16:35
Mad VIM Skills #18

Use :Ack --type [type] [pattern] to search for [pattern] only in files of [type] with ack.vim. Check available types with ack --help-types. E.g.: Ack --type js forEach.

@BastianHofmann
BastianHofmann / mad_vim_skills_17.md
Created October 19, 2018 13:14
Mad VIM Skills #17

Use *:Ack to search for the word under the cursor in the current directory with ack.vim.

@BastianHofmann
BastianHofmann / mad_vim_skills_16.md
Created July 12, 2018 14:56
Mad VIM Skills #16

Use gq to wrap the currently selected lines to the textwidth setting (gqq to wrap the current line and gqip to wrap the current paragraph). BTW: The vim-editorconfig sets the textwidth to the specified max_line_length.

@BastianHofmann
BastianHofmann / mad_vim_skills_14.md
Last active June 18, 2018 09:40
Mad VIM Skills #14

Use b# to switch to the previous buffer (i.e. the file which was previously edited)

@BastianHofmann
BastianHofmann / mad_vim_skills_15.md
Last active June 20, 2018 06:37
Mad VIM Skills #15

Use vim -oN to open VIM with N horizontal splits. Use vim -ON to open VIM with N vertical splits.

Edit multiple files in a row

You can open multiple files and edit them in a row (e.g. vim *.json or vim a.txt b.txt). Use :wn to write the current file and open the next.