vimの最近見つけた便利コマンド

Linux
Screenshot 2013:02:14 19:16-5


あまり日本語で紹介されていない、vimデフォルトの便利コマンドを2つ。

:saveas {file}

保存して開く。

今までは、:w newfileしてから、:e newfileしていたけど、一発で出来る。

:sav newfile
:sav :saveas
:sav[eas][!] [++opt] {file}
                        Save the current buffer under the name {file} and set
                        the filename of the current buffer to {file}.  The
                        previous name is used for the alternate file name.
                        The [!] is needed to overwrite an existing file.
                        When 'filetype' is empty filetype detection is done
                        with the new name, before the file is written.
                        When the write was successful 'readonly' is reset.
                        {not in Vi}

:qa

全バッファーを閉じる。

最近は、1ウィンドウに6ペイン x 5タブ くらい開いていて、コーディングがおわったら一気に閉じたいけど、:qを20回ぐらいやってましたが、これで一発で終わる!

もし、未保存があったら途中で止まります。!つけると未保存関係無しに閉じます。

:qa :qall
:qa[ll]         Exit Vim, unless there are some buffers which have been
                changed.  (Use ":bmod" to go to the next modified buffer).
                When 'autowriteall' is set all changed buffers will be
                written, like :wqall. {not in Vi}

コメント