vimの覚え書き

.vimrc
“set fencs=utf-8,sjis,euc-jp
set encoding=utf-8
syntax on “Enables syntax highlighting for programming languages
set number “Enables line numbering
set nobackup “when not wanting to backup

set nocompatible “This fixes the problem where arrow keys do not function properly on some systems.
“set showmatch “Highlights matching brackets in programming languages
set cursorline “add underline in cursorline
set incsearch “incremental search
set autoindent “If you’re indented, new lines will also be indented
set smartindent “Automatically indents lines after opening a bracket in programming languages
set backspace=2 “This makes the backspace key function like it does in other programs.
set tabstop=4 “How much space Vim gives to a tab
set smarttab “Improves tabbing
set shiftwidth=4 “Assists code formatting

“statusline
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2

大文字・小文字変換
guw 単語を小文字にする 
gUw 単語を大文字にする
gugu 一行を全て小文字にする 
gUgU 一行を全て大文字にする
コマンドモードから
:% norm gUgU

シェルのコマンド実行
temp.txtをawkを用いて10行目以前をクリップボードへコピー
:!awk ‘NR<=10{print $1}' temp.txt | pbcopy 文字数カウント
‘.’は任意の一文字を検索、’&’はマッチした一文字を返す。結果の置換数が文字数
:%s/./&/g

単語数カウント
:10,15 w !wc -w

行指定でpbcopyしたい
! awk ‘NR==9,NR==10’ note.txt | pbcopy
“:1,5 w !pbcopy”でもできる