Vim Surround
Hôm nay ta sẽ tìm hiểu vim plugin 'vim surround'. Để cài đặt vim surround ta thêm vào file '~/.config/nvim/init.vim' dòng sau.
Plug 'tpope/vim-surround'
Sau đó save, update và install
:w
:so %
:PlugInstall
Bây giờ ta sử dụng vim surround nhé. Ví dụ ta có đoạn text là Hello word.
Để chuyển thành
"Hello world"
Ta gỏ như sau: yss"
"Hello world"
Để chuyển thành
'Hello world'
Ta gỏ cs"'
'Hello world'
Để xóa '' ta gỏ ds'
Hello world
Ta muốn text trên trở thành
<div>Hello world</div>
Ta gỏ yss<div>
<div>Hello world</div>
Ta muốn xóa div trên ta gỏ dst
Hello world
Ta muốn đổi text trên như sau
<h1>
Hello world
</h1>
Ta gỏ VS<h1>
<h1>
Hello world
</h1>
Nếu ta muốn thêm như sau:
<h1>
<span class="mySpan">Hello</span> world
</h1>
Ta đưa con nháy vào chữ Hello và gỏ
ysiw<span class="mySpan">
<h1>
<span class="mySpan">Hello</span> world
</h1>
Như vậy là ta biết cách dùng vim surround rồi nhé.