Vimの置換で改行を入れるTips
しょっちゅう忘れる改行をいじくるメモ
hogeの文字の後に改行:
s/hoge/hoge^M/g
^MはCtrl+v,Ctrl+mで出せる。
改行を消す:
s/\n//g
また、vim置換をさらに便利にするために、範囲指定の置換と問いかけの置換も覚えると便利です。 (勝手に命名)
範囲指定の置換
'<,'>s/hoge/fuga/g
visual modeで範囲指定後実行。範囲内しか置換しない。置換した時によくある他への無駄な副作用をなくす。
問いかけの置換
s/hoge/fuga/gc
cを最後に入れるだけ。置換対象の要素をそれぞれ置換するかどうか聞いてくる。 yやnで答える。困ったらCtr+Cで置換を取り消す。
より慎重に置換したい場合に便利。
参考
MacPortからHomebrewへの移行方法
以下ページに従ってmacportをOSX10.10.5で使えるようにする。 そもそも、macportだけをアンインストールしようとしても、以下エラーでできない。
Error: Current platform "darwin 14" does not match expected platform "darwin 13" Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration OS platform mismatch while executing "mportinit ui_options global_options global_variations"
そこで、回り道になるが、macportをOSに合わせたものをインストールしてきて、 それをアンインストールするという手順を踏むことにする。 手順は以下。
- Xcodeを再インストール
- MacPortsを再インストール
- MacPortsでインストールしていたものを書き出して,一度全て消去.書き出したリストを使ってもう一度インストール
1. xcodeのインストール
インストールはせず、以下コマンド叩くだけ。
sudo xcode-select --install sudo xcodebuild -license
2.「MacPortをインストール」
https://www.macports.org/install.php
このページからOSに該当するもの持ってきてダウンロード&インストール。
3.
※ 3.はもしかしたらこの手順すべてはいらないかもしれません。一応Migrationの手順に沿ってます。
port -qv installed > ports.list
とかでインストールしていたものを書き出し、
sudo port -f uninstall installed
sudo port clean all
で一度全て削除。
以下、スクリプトを持ってきて再インストール。
curl -0 https://svn.macports.org/repository/macports/contrib/restore_ports.tcl
chmod +x restore_ports.tcl sudo ./restore_ports.tcl ports.list
アンインストール
次に、アンインストールする。
$ sudo port -fp uninstall --follow-dependents installed
残りの設定ファイル等を削除する。
sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports
~/.bash_profileからMacPortsインストール時に追加した以下のPATHを削除。
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Homebrewのインストール
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
これにて完了。