How do I select all the content of a file in Vim and VsVim? Like in other editors Ctrl-A does the job for select all.
Along with SibiCoder's answer, if you have a clear idea of what you want to do you can use the following:
X is a command, for example:
:%d -> delete every line :%y -> yank every line :%normal! >> -> indent every line
You have also the global command
:g which, with the search pattern
^, can do the same thing:
:g/^/d -> delete every line :g/^/y -> yank every line :g/^/normal! >> -> indent every line
If what you want is selecting the text, then
ggVG is fine, but keep in mind these method, in the case you already know what is the next step. Note that it won't leave the cursor in visual mode.
:h :% and
:h :g for reference.
Note that, even though the
C-A mapping is used in vim (see
:h CTRL-A), you can map it to do what other editors do:
nnoremap <C-A> ggVG
Just be aware that mapping
C-A could clash with other plugins' mappings or with
screen's default prefix.
The other answers are good. Here's another alternative.
Since you mention that you are using VsVim, you can change which keys are handled by visual Studio, and which keys are handled by vsvim. Go to
Tools -> Options -> VsVim -> Keyboard
From there you can set Ctrl-a to be handled by Visual Studio, rather than VsVim.
Although I do not recommend this since you will not be able to use vim's
<C-a>, which I find to be an essential feature. Though it's up to you.
If you'd like a faster/more intuitive way to do this and don't mind adding a plugin, this looks handy: https://github.com/kana/vim-textobj-entire
I used to use
map <leader>a ggVG to select all, but later I found that
Ctrl+V pasting has an extra new line. So nowadays, I use:
map V 0v$ map Vk $v0k map <leader>a ggVG
Which works without side effects.