juleslasne
juleslasne

Reputation: 570

Vim does not like brackets

I have a problem that have been bothering me for days now.

Whatever I do, I simply cannot place any single {,},[ or ].

Every time I try, it takes me up to the next or previous paragraph. I've looked it up and I can't find a good way to unmap it and finally have my azerty keyboard to behave correctly so I can peacefully code

Upvotes: 0

Views: 889

Answers (4)

juleslasne
juleslasne

Reputation: 570

Alright, Problem Solved ! I had to uninstall and reinstall the Ubuntu bash on windows 10 multiple times and it worked ! Thanks for the help everone !

Upvotes: 0

DevSolar
DevSolar

Reputation: 70343

Vim / vi has several different modes. This dates back to the times when you would edit using a teletyper, i.e. no "visual" representation of the data you are editing, no mouse etc.

With only the "usual" keys at your disposal, you need to navigate in the data, you need to insert data, and you need to execute commands on the data. Not so coincidentially, these are the three modes of Vim / vi, and in each mode, the keys do something differently.


By default, the editor starts in the "normal mode", which you will use to navigate, and enter the other modes from.

In this mode, ) moves you to the end of the sentence, ( to the previous sentence. } and { do the same for paragraphs, combinations of [ and ] work with chapters.

If you enter "insert mode" (most simply by pressing i in "normal mode"), you can enter all the above letters normally. You exit "insert mode" by pressing <Esc>. You will recognize "insert mode" by -- INSERT -- being displayed in the bottommost line of the screen.

If you are in "insert mode", and pressing any of the above keys does move your cursor instead of entering the corresponding symbol, there is some (broken) configuration at work. Check your ~/.vimrc, and if necessary, rename it and try again with a "clean" configuration.


It is next to impossible to do Vim / vi justice in the scope of a SO answer. It is very much an expert-friendly editor, not a novice-friendly one. You need to actually learn how to use this editor, but it is absolutely worth it in the long run.

Upvotes: 1

CWLiu
CWLiu

Reputation: 4043

In the normal mode, press 'i' to enter the insert mode. And you can start to edit your file.

After everything is done, press the 'ESC' key and then ':wq' to save your modification.

Upvotes: 2

nobe4
nobe4

Reputation: 2842

In insert mode, you should be able to insert brackets without trouble.

In normal mode, those correspond to motions.

To go to insert mode from normal mode, press i.

See: :h object-motions

Upvotes: 1

Related Questions