Vim - how to start inserting at the end of the file in one step

后端 未结 5 1938
甜味超标
甜味超标 2021-02-01 00:48

Is there a single shortcut to start inserting in the new line at end of the file?

I\'m aware of G + o combo.

相关标签:
5条回答
  • 2021-02-01 01:10
    echo >> myfile.txt && vim -c 'startinsert' + myfile.txt
    

    You can also save the above command in a script and then use $1 instead of myfile.txt, name your script myvim ( or whatever you like ) and always open your files and start writing away instantly.

    myvim myfile.txt
    
    0 讨论(0)
  • 2021-02-01 01:14

    You could stick the map definition in your .vimrc and then invoke it when the you open the file.

    Or, if you only want to do this for a particular file, you could create an autocmd for that file type that does it automatically. See autocommand in the vim doc's.

    0 讨论(0)
  • 2021-02-01 01:17

    There's also the command line option "+":

    vim + myfile.txt
    

    Will open myfile.txt and do an automatic G for you.

    0 讨论(0)
  • 2021-02-01 01:31

    Adding the following into ~/.vimrc will create one for you:

    :nmap ^A Go
    

    To type the "^A" first press Ctrl-V, then press Ctrl-A. You can then use Ctrl-A to append at the end of the file when not in insert or visual mode.

    0 讨论(0)
  • 2021-02-01 01:36

    Not that I know of - G+o is what I would have suggested too, but that is 2 steps :)

    You could always create a macro which does G+o, and then you can invoke the macro which will be 1 step.

    0 讨论(0)
提交回复
热议问题