Score:4

Is there a command to move a cursor to a specific line when creating a new file in vim?

ng flag

I am new to ubuntu. I am using vim for quite sometime now. I came across autocmd BufNewFile command to automatically add some text when a file with some particular etension is created.I have attached the pic of how it looks after that command. But I want the cursor to be in a different position rather than line 9. DEFAULT I want the cursor to be on line 6.example of what OP wants

cocomac avatar
cn flag
Welcome to Ask Ubuntu! Just so you know, there is also [a Stack Exchange site specifically for Vi and Vim](https://vi.stackexchange.com/). Of course, [make sure your question would be on-topic there](https://vi.stackexchange.com/help/on-topic), and please [_do not_ post an exact copy of your question there](https://meta.stackexchange.com/q/64068/1081494). Your question is good here, but I wanted to let you know about that site as well.
nl flag
@Algnis Please don't put a signature inside image alt text. If you don't want to create alt text that's fair enough, but please don't put incorrect information in instead. Thanks!
Score:4
in flag

If you want to move to (for instance) line 10 in the file, you would type :10

You can put commands like this on the command line with vim +10

muru avatar
us flag
In this case, OP just needs to add `| :6` their `autocmd` to have the cursor be at line 6 when the autocmd completes.
ng flag
It's also possible to go to a particular line (and column) py appending a ":normal" command to the command line, like: `vim '+normal 6G10|'`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.