How to delete one word backward in Vim

The following is a sample of text opening in vim/neovim with line numbers: 1 What would be the command to delete one word backwards? 2 I know we can use ‘db’ to delete backword, and it would work 3 as what I wanted if the cursor is on the last character. Assuming that my cursor is under letter ‘a’ of the word ‘command’ in line 1, and I want to delete the whole word ‘command’....

August 8, 2023 · 2 min · 322 words · kenno

Vim Replace String 256 with <T_CO>

What was your first text editor when you started using Linux/Unix? Mine was pico. It was very easy to get started with and quite similar to nano. Then I moved to emacs and sticked with it for a long while. Eventually, I’ve switched to vim (or neovim), and that’s what I have been using until now. Well, the thing about text editor or may be this also applies to many other things, you’re only familiar with features that you constantly use....

May 9, 2021 · 2 min · 320 words · kenno

How to remove Ctrl-M characters from files

A short while back, after exporting my blog from WordPress to Hugo I noticed that there were some weird ^M characters in some files as shown in the following screenshot in blue. This is a special character, CTRL+M and can be removed using sed or vim. Using vim we can replace/substitute a text with the following command: %s/MATCH-TEXT/WITH-NEW-TEXT/g Therefore, we should be able to replace ^M, by typing CTRL+V then CTRL+M, with an empty space as so:...

January 6, 2019 · 1 min · 133 words · kenno

Remove trailing whitespace with VIM

Here’s a quick tip on how to get rid of unwanted trailing whitespace using vim. Let’s say, I have the following code: Open that file with vim. The following command deletes any trailing white spaces. :%s/\s\+$//e Here’s the screenshot of the text after removing the whitespace: In search, \s finds whitespace (a space or tab). \+ finds one or more occurrences. $ matches the end of line, finally e flag means no error is displayed....

July 27, 2017 · 1 min · 96 words · kenno

How to toggle between buffers in Vim with vim-airline

First if you haven’t yet heard about vim-airline plugin, and you’re a Vim user, you really owe it to yourself to check it out. By default vim-airline displays the opening buffers on the top part of the window. So how to navigate between those buffers? Well, according to this, it seems those buffers are for visual only. To navigate between them, we can use :bp for previous buffer, and :bn for next buffer....

January 29, 2017 · 1 min · 116 words · kenno